It's not just google. It's adservers in general. When you go to site A, a cookie file is placed on your computer from the adserver they use. All of your searches are recorded.
When you go to site B that also uses the same adserver (probably google ads), it knows exactly what you're probably after and will serve up the ads accordingly.
The internet is surfing you. With that said, you can clear out your cookies regularly or just block them all together, but that could be more trouble than it's worth.