That’s a superstition created exactly by the other information-gathering they do—and the information they
share.
You might think that Facebook knows about what you’re thinking about buying on Amazon because you’re talking to your spouse out loud about buying that thing. But more likely than not, it’s because you also mentioned it on Facebook Messenger — or Instagram, or WhatsApp. Or, because you already searched for the thing on Amazon, and Amazon sold that data to Facebook. Or because you watched a video about it on YouTube, or read a review article about it (which is what inspired you to be interested in buying it in the first place), and YouTube or that media conglomerate sold your data to Facebook/Amazon/etc.
Likewise, if Amazon knows about your Facebook activity, that’s likely an example of data-sharing in the opposite direction — Facebook selling to Amazon.
Of course, both Amazon and Facebook also partner with tons of other smaller third parties as well, to do ad-tech targeting that those third parties don’t bother to do themselves.
Something people always wonder about is how Tumblr still exists, despite having the worst internal ad-tech ever. Well, they don’t need to make money showing you ads themselves; they can just sell your data to Facebook/Amazon/etc., to improve their ad targeting of you.
Same goes for, say, Wordpress. Just because a blog doesn’t have ads on it, doesn’t mean it isn’t collecting your data and feeding it into one (or multiple) of the big five’s ad-tech backends.