Amazon sells illegitimate books with identical covers to a legit copy and keeps selling them after the authors contact Amazon .... like it's not even hard to detect those, but they don't.
Amazon simply didn't care when fakes started showing up, missing pages, bad printing, but the covers were always identical.
Apple wanted to control unauthorized (even authentic) sellers, Amazon wanted to buy directly from Apple and carry more of their products, they negotiated and reached an agreement.
Amazon has rolled out Transparency, which is a way for any brand, regardless of size, to cheaply block the vast majority of counterfeits by putting a unique label on every product. Brands can also file complaints against counterfeiters which get acted on very quickly.
I suppose a manufacturer with the current system could hide quantities by generating way more codes than they actually need and only using a small percentage of them.... even with that Amazon could detect which ones were scanned and how often, so the manufacturer would have to randomly scan the unused codes, and maybe rotate the IP addresses they use!
An open protocol not controlled by any one player would be much preferred.