It's most likely done with trackers. Apps today are now, for the most part always including Trackers. Yes, you've read about Ad-Sponsored Apps but there's more. There's always more.
Take a look at https://imgur.com/gallery/dumrc to start your journey of learning about Trackers in Apps.
I can only hope that we see a way to submit an App to see what's inside. But in short, if you use an app with trackers, that can leak as you noted then cause Google Ads to use targeted ads.
From the link above, some information you need to know about these trackers. WHAT ARE THEY DOING?
Flurry and Nexage are two of the trackers, and if you go to the above page, you will find that there is a collected information page that details some of the behaviours of the apps.
Flurry in particular, is a Verizon/Yahoo (now called Oath) venture that will, undoubtedly raise hackles.
https://arstechnica.com/information-technology/2017/06/oath-verizon-completes-4-5-billion-buy-of-yahoo-and-merges-it-with-aol/Flurry watches how you interact with other users in the app, and culls a lot of other data to create and individualized portrait of you as a consumer.
https://reports.exodus-privacy.eu.org/trackers/25/Nexage is also an Oath product that precisely monitors your individual usage, your location using all available suites like Cellular/Wi-Fi/Bluetooth/GPS, which makes me wonder if they're accessing this information while the application is off because these all can be accessed while they're turned off in some phones) and will associate all that recon data with all other information. They also state …