Sales are accounted for in $ terms, not units sold. It's the same thing with Hollywood. You might think movies are more popular than ever thanks to record breaking sales (pre-COVID at least). In reality, we reached peak movie, in terms of tickets sold, in 2002! [1]
Back to iPhones, this [2] page shows their stats by units sold (about half way down). iPhone is essentially treading water if those data are correct (with a peak in 2015 overcome twice since, but by ~1% each time), but I strongly suspect that that's showing units shipped and not units sold, as iPhone sales declining has been universally reported.
Ask yourself the question of what it means when a company makes more dollars from a product while not increasing the number of units sold. It's completely obvious if you think about it for a moment.