There are three kinds of ads.
Heat seeking missiles [BAD] Data aggregators purchase your data, analyse your location, purchase history, browsing history, app usage, and more, then create a complex profile of you with AI assisted inference. They guess, (and nearly always accurately) your income, hobbies, education, age, gender, and most worryingly, your most likely future purchasing behaviours. Then they sell this data to advertising networks.
These shadow profiles are so incredibly accurate that they’ve given rise to the “my phone is listening to me” myth.