It's called plausible deniability. It doesn't matter whether they know, what matters is whether you can PROVE that they know.
That's a bit of an oversimplification. I'm quite certain that the Pirate Bay is fully aware of what is going on (they
are called The Pirate Bay after all) but with millions of transactions going on pretty much at all times, they couldn't properly police it even if they wanted to. It's the exact same reason that trolls exist on platforms like YouTube and Facebook. There's so much going on all the time that any attempts to gain control of it would be a very expensive exercise in futility.
In the case of these sites, I don't think that it's so cut-and-dry because from what I've seen, the overwhelming majority of what goes on is legal. I've purchased many keys and they've all worked 100% without exception or time limitation. I think that if ANY of these sites sold actual stolen keys, it would seriously hurt them because people are already suspicious as to how they're able to do what they do.
Imagine if you bought a key and were informed that it was a stolen key. You'd probably feel rather embarrassed, angry and extremely apprehensive about EVER buying ANYTHING from that site again. At least, I know that I would. To give it a test, I ordered Windows 10 Professional x64, bundled with MS-Office from Kinguin several years ago. There have been no adverse reactions from either Microsoft or from law enforcement. So I got some games like Injustice 2, Rise of and Shadow of the Tomb Raider, Far Cry 4, Far Cry 5, etc. and to this day, no problem. I only paid an average of about $25CAD per game and they have all worked perfectly.
My personal experience over the years has been that these sites are extremely trustworthy and they have to be because the second that people stop trusting them, they die. It's why I don't ever worry about ordering from eBay despite their rather checkered distant past. I know that they're extremely motivated to shed any stigma that they may have been stuck with.