This is not true for all products. Some are sold under a pay-per-scan model, where the product is owned by the supplier up until the barcode is scanned at checkout, whereupon it is immediately purchased by the store and sold to the consumer.
For other products, suppliers may also be required to accept unsold goods for a full refund of the store’s purchase price.
Stores are marketplaces too, and shelf space – particularly the valuable shelf space like end caps – is not free.
But pay-per-scan is much more common. Examples include everything from trading cards to makeup to sandwich bread. The supplier will often restock these products themselves, so the store doesn't even need to track inventory.
Walmart does this too. Newegg made the switch several years ago. Large retail outlets which do not have a "marketplace" online option are the exception rather than the rule.
Different companies do different levels of vetting, but the retail ecosystem is vastly more accessible to small-timers than it was in the 2000s.
Amazon is a marketplace, and pays nothing to buy your products when they're offered for sale on its virtual shelves. It purports to provide an open and equal common area for companies (including itself) to sell products, yet only Amazon has access to the treasure trove of data about the behavior of consumers on its site.