There was a planet money episode about this exact comparison the other day. Basically it comes down to:
When a grocery store puts something on it's shelves, the store itself bought it from the manufacturer. They have already made their money. On Amazon, manufacturers don't make money when the item is listed, they make it only if and when a customer buys the product.
When a grocery store makes its own novel product and puts it on the shelf, it's taking a risk. If they make those products, but they don't sell, they just lost a bunch of money. Or, if their product is a competing one with an existing product, they know that products like that can sell, but now they have to focus on outselling the original product. When Amazon makes its own product, most of the risk has been removed. They pretty much already know it sells well on their platform, and they have enough money that knocking 5 dollars off the price, making it prime recommended, and putting it at the top of the list will cause it to beat the competition 9 times out of 10.
I'm not saying any of this is fair or unfair, because I'm not an economist so I don't believe I have a full understanding of the situation.
I tried to find the exact episode but it seems I can never find them when I need them.