Walmart is not just a supermarket. They sell a wide variety of goods—and since my wife was in the wholesale costume industry for a while, I happen to know that they tend to have retail margins of roughly 50% (or at least, they did 10 years ago).
Walmart does tend to operate more on volume than margin, but they're definitely not stuck with grocery margins on everything.
Grandparent's 5% or less is "earnings as a fraction of revenue", which is called "net profit margin" or just "net margin", whereas your 50% is gross margin.
According to an LLM I just consulted Walmart's net margin for the last 5 years for which we have data never got above 3%.
To calculate net margin, we include every expense, e.g., management salaries, e.g., the cost (rent of depreciation) of the stores. To calculate gross margin, we include only the expense of obtaining (buying or making) the goods solds.
When considering whether a retailer can eat the cost of tariffs or must pass them on to the consumer, net margin is more relevant than your figure, which is gross margin.
As someone else mentioned, that's gross margin, ie revenue minus cost of goods sold. I think in the tech industry we tend to fixate on gross margins, on the basis that for your average SaaS there's virtually an infinite market, and other costs won't scale linearly as it is addressed, so net margin really is less important (mind you, people sometimes go a bit too far in discounting it) but for, say, a gigantic retail chain, things are different. Walmart can't just scale up its sales 10x, and even if it could it would need lots of new premises etc. For Walmart, what really matters is net profit margin, and that is low.
Walmart does tend to operate more on volume than margin, but they're definitely not stuck with grocery margins on everything.