If you add a shortcode programmatically, but the code isn’t viewed on that request, is it still executed?

Shortcode callbacks are not executed unless the shortcode is parsed and executed. So if a shortcode has been added, its callback will not run unless the shortcode has been used somewhere on the page, or executed manually in a function or template that has been used, and it will only be run at the moment that the shortcode is parsed.

So the act of registering a shortcode with add_sortcode() alone will not execute the callback function.