Less people are upgrading every year or even every few years. Also, Apple's manufacturing process is getting more complex especially for the materials used to build the Pro iPhones. The overall bill of materials is more expensive, the 3NM SoC from TSMC, the manufacturing of the near edge to edge display and just engineering that into a working product. With the fact we are keeping these expensive devices longer, Apple wants to get as much out of new users and upgraders.
Apple also make more than 50% margin on every iPhone they make which is why they are worth nearly $3T at this point. You’re right less people are upgrading but also less people go for Pro devices too. Increasing the cost just makes the segment even smaller again. I know people here will suggest higher prices are ok because people will absorb the cost and keep the phones longer, but many don’t want higher bills initially either.