Hardware isn’t everything. Apple has a couple of advantages over iPhone that let them do more with less:
iOS needs to support a MUCH fewer devices than Android. Even before they switched to their own silicon, they’ve been optimizing the OS to the hardware really well giving you devices that go toe to toe with Android flagships of the same generation with SIGNIFICANTLY better hardware and like double the RAM. Also why Apple doesn’t really care to increase RAM as much as the android side of things.
Apple silicon is actually really good and making their own hardware allows them to optimize on both sides of the equation and lets them do more with less.
The selling points for Android (at least the way I’ve seen it over the years) have always been full control (talking about non-root, I’d rather not go down the root rabbit hole here) and (since iPhone 11 started doing firmware blocks on parts) reparability…but both seem to be going out the window lately.
Prices are crap though, but then again Android phones on the top end don’t seem much better. 1-2 gen old iPhones are usually a bit more reasonable though tbh.