So. Tricky subject. Amazon / google doesn't really want sites talking about it as that will draw attention to ads for the purpose of driving purchases or clicks. Or even threads dedicate to talking about said adds. They want it to be all natural and are very strict about anything that could be construed as manipulating the visitation of the ads.
With that said, since its been asked, we are an affiliate. If you click on the banner then anything you buy after that we get a small commission. A couple percent. That is in no way me asking you to do that however.
As for how they work its Amazon / googles proprietary formula. They may show things that you have looked at on amazon or the Internet. They base this off your browser cookies. Or they may base it off the prominent content of the page, such as motor oil, if none of the above, then generic stuff the formula thinks you might be likely to buy.