A lot of audio ad broadcast software uses a combination of audible or inaudible tones to act as "triggers" to mark a location where an ad can be injected using some kind of location/time/etc aware data, the ad itself is very rarely baked into the stream unless it is something you're listening to a host read themselves.
In podcasts, the ad injection software will often pause the audio at the point where the ad tone occurred while it plays the ad, and resume it afterwards for continuity.
How does this work with a typical podcast player? The media download is typically just an mp3. The podcast software maker would have to be in on the scam otherwise it's an mp3 that plays from beginning to end.
When your player requests the mp3 file in this example the server on the fly can generate an mp3 file that your player then downloads. This means that they can serve different ads in old podcast episodes or even remove them in old episodes.
I've seen this too. A politics podcast I listen to on Spotify played me some targeted get-out-the-vote messaging about my local & state races in November. I'm assuming Spotify provides them that data via customer's billing addresses. Or maybe they get it from location sharing via Waze (which has Spotify integration).
I think the MP3 gets generated based on location.