There’s a lot that goes into it. I’m mainly talking about iPhone, because I’ve personally only been disappointed in expensive Android phones.
Camera, as you mentioned. But also the build quality, the display, the longevity (software updates last for years, so you can wait 4 or 5 years to upgrade). Personally I much prefer the software experience of iOS vs Android. The speed of the device, where you’re never waiting for something to respond.
But I once you go to the high levels, and looking between the normal and ‘Pro’ versions of flagship phones, it’s just the camera that separates them.
Like most things, you get what you pay for.