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.