This is incorrect. I wish people would stop repeating this in this thread. Some stores purchase their stock. But the really big players do not operate like that.
When you go into Target and go to the cracker aisle, Target has not actually purchased all of the cookies and crackers that you see on the shelf. Target effectively rents out shelf space to Nabisco, who then comes in and puts their items on the shelf (or will pay Target to take the product and put it on the shelf for them). The pricing agreement can get quite complicated and depends on the amount of shelf space, location in the store, and can also depend on number of items eventually sold... but the takeaway is that Target does not just outright buy boxes of Oreos and then try to resell them. If the Oreos don't sell (say perhaps because the customers opted to buy the Target brand sandwich cookies instead), Target isn't out any money, because they still got their shelf rental fees from Nabisco.
Going even further, Target also engages in the same type of activity Amazon does with their analytics (including sales volume, margins, customer profiles etc) and use that information to decide who gets to rent how much shelf space and where. Target et al spend incredible amounts of money optimizing this stuff, which isn't far off from what Amazon does.
People have this old rusty view of brick & mortar stores, but the reality is that they've been masters of this stuff far longer than Amazon has even been around. Amazon championed bringing these practices to the online space and became the most obvious juggernaut, but that doesn't mean these other companies are angels.