For a long, Apple didn't really care about building cheaper phones, they just cared about a very specific, lucrative part of the market. While these days, there is an absolutely huge difference in price between the most expensive iPhone to their more budget models, I think the fact that iPhones are only ever produced by one company allows them to control its public image in a way that Android never can. There's some amazing Android phones, there's also some real garbage ones, with terrible custom UIs, poor support and a bad user experience. Even an iPhone SE, runs some pretty amazing tech, has great production quality and Apple supports it for longer than most flagship Android phones, so no worries if you will get Android 15 or whatever.
And when it comes to tablets, this is even more extreme, with the Android space being a complete joke, while the iPad actually has a large selection of decent apps tailored to it.