Because they aren't doing the same thing.
In reality, if you understand their business model and culture you could see that Walmart won (ie, killed off independent retailers) in an age of scarcity, where controlling supply was the key to success.
As a result, their ruthless and penny-penching culture made them the best at a certain game (lower prices as the result of true globalization and commodification of every possible thing Americans would want to buy) by specifically focusing on and optimizing for scale (both in the store and diversity of SKUs and in their footprint) and making every thing else a process that could operate at the least-common denominator, thus allowing them to treat their employees as just another replaceable cog in a humming machine.
This is the same world that made newspaper publishers the richest people in their communities, and often in the world.
We now live in a world where the power does not lie in controlling supply, but in being the source of aggregated DEMAND.
So just as a newspaper can't charge a king's ransom to sell a local business an ad, the only real way to reach the audience at scale in his market, Walmart can't (or maybe can't) be as ruthless in squeezing their suppliers to death, exploiting globalization and have a customer-agnostic culture and just expect to "win" because they are either (or both) cheaper and more convenient than another retailer.
To get your product in Walmart's stores might take years, massive capital investments to scale up your production, and more, only to see your business get squeezed at every possible turn. But now you can launch a new product on Amazon, with theoretically a larger reach than even WMT ever had, in minutes and scale as your sales scale.
Because Amazon is increasingly driving demand in all online commerce, they are also growing a marketplace where any retailer can reach the world's (or at least the affluent customers of the US), and all they have to do is pay them a small percentage of what they sell in exchange.
Amazon is not really interested in cutting costs just to spite their customers, as they want to continue to drive more and more of the demand, while forcing suppliers to come on their platform to sell, and thus reap a small "tax" on every retail transaction.
There is no limit on shelf space at AMZN, much less a limit on departments, and with aggregated demand even the most niche players can find the very specific market they are looking for and build a successful business.