Walmart sells more of just about everything than pretty much any other seller, and it sells many products for less than anyone else. Taking that into account, Walmart could make more money even if the margins are smaller.
If the corner store sells three razors for $2.99 that it bought at wholesale for $1.99, that shop just made $3, for example. If Walmart sold the same three razors for a lower price of, say, $2.49, it would have made only $1.50.
But when it does that another 10,000 times in a single day and also sells cat litter, fresh lettuce, basketballs, blue jeans, and everything else, its tighter margins have little appreciable impact on overall profits.