How do you figure? Compare this for Amazon:
Amazon has separate retail websites for United States, United Kingdom & Ireland, France, Canada, Germany, Italy, Spain, the Netherlands, Australia, Brazil, Japan, China, India and Mexico. https://en.wikipedia.org/wiki/Amazon.com
To this for Walmart:
As of January 2014, Walmart's international operations comprised 6,337 stores[1] and 800,000 workers in 26 countries outside the United States. https://en.wikipedia.org/wiki/Walmart
And this map for Walmart: https://en.wikipedia.org/wiki/Walmart#/media/File:WalMart_in...
Diversified into lots of "nice to have" items. In a really bad economic downturn, Amazon would be wiped off the map. People would still be buying bread and milk at Walmart.
Yes, for certain commonly-consumed heavy or bulky goods, i.e. anything that's either mostly air (like toilet paper) or mostly liquid (like detergent) they aren't your best choice. That's not all goods by any means.
Also you're comparing the mileage of a bus (the UPS truck) to a passenger vehicle. The UPS truck is delivering goods for a hundred other people on his run today, the gas spent transporting your package is an absolutely insignificant fraction of that. If you're really worried about ~my carbon emissions~ then you should really be thinking about ditching that car and getting yourself to work on one of those 5 mpg busses.
In fact where I live Tesco recently raised their free-delivery minimum order threshold to try to encourage people to place larger, pre-planned orders.
Most of the stuff that you'd buy at a real-life grocery store doesn't make sense to order shipped from Amazon. Amazon as a replacement for WalMart only makes sense if you can wait a few hours for delivery and live in one of the selected areas for Fresh.
Portions like AWS, Digital and 3P/FBA service revenues will have much higher margins than first party retail revenues (which is the most like Wal-mart revenues, except the margins are completely different due to no having brick-and-mortar stores.). Additionally, Amazon is a lot more international than Wal-mart so comparison is even harder.
All of this completely ignore the growth rates of these two companies.