Apple is seen as premium brand by most of their customers who are willing to pay more just for that alone.
Overpriced image is certainly justified based on price they charge for upgrades (8gb to 16gb, 256gb to 512gb etc).
In my experience Apple hardware is on par with the rest of the major brands, some models might be better, some worse, as is the case with all manufactures but Apple users usually stick with Apple even after bad experience and are willing to pay extra for initial purchase, extra for upgrades, extra for insurance plans that are almost mandatory, and extra for peripherals.
People who shy away from Apple are usually less inclined to pay extra for things that they believe should be included or "premium" brand peripherals and upgrades, and are also willing, and able, to switch brands if they receive faulty hardware or poor service.