Hi,
this will happen in Google Tag Manager in preview as well, as variable values are displayed for every event. This means, that if you log something to console in your variable code, you will see a lot of executions while in preview and significantly less when looking at a site using a live container without preview mode.
However, if a value does not change all the time and every execution will return the same value, just cache it in a JavaScript variable and return that value if present until the next page loads. That’s a good idea in every tag manager, I guess.
best,
Markus