These are units SHIPPED, not sold. Most of them are probably sitting in the backs of stockrooms and in warehouses. Shipped means nothing, you want to look at sales.
For Apple, units shipped typically correspond with units actually sold to customers.
For other OEMs, analysts tend to conflate units shipped with units sold. To put it another way, units shipped doesn’t measure which phones are currently in use or even what consumers are buying during any given period. Like you said, they could still be collecting dust in a warehouse somewhere, but this is likely more true for android phones than iPhones.
Meanwhile, units sold reflects which smartphones are actually being used and worn, and this is the reason why the iPhone rates so highly in usage metrics despite their apparently low market share. My belief is that the actual active iPhone user base would end up rating much higher than shipment data implies.
This is also why you can have reports like the iPad or AirPods market share dropping due to an apparent influx of cheap alternatives, only to realise that nobody is actually buying these cheaper offerings in any meaningful quantities, nor are they actually do much to dent the popularity of said apple products. What typically ends up happening in the end is that instead of taking share away from the high end, the lower-end competitors just end up cannibalising each other, and some players will eventually end up leaving the market due to lack of profitability.
All while Apple continues to rake in the lion's share of profits in the industry.
Ecosystem strength is mattering more and more these days. It's no longer enough to just be able to ship a smartphone or a pair of wireless headphones at a competitive price or with compelling features. Instead, consumers are increasingly looking for a range of products that seamlessly work together, and this is why I believe Apple will continue to prosper for a good many years to come.