This isn't really true. Costco carries less than 4000 SKUs in its warehouses. Walmart carries 40000 SKUs. That's an order-of-magnitude difference.
Costco competes more with (Walmart's) Sams Club warehouse but based on my shopping, their product selections don't overlap. (E.g. Costco has high-end wine that Walmart/SC doesn't carry.)
To make Costco vs Walmart an apples-to-apples comparison, Costco would have to eliminate the $60 to $110 annual membership fees, allow any non-member to shop there, and add 45000 additional SKUs.
I don't know anyone who shops at both Walmart and Costco on a regular weekly basis. Their business structures attract very different shopper demographics.