In case of the capacitor, if you knew all the specs of the capacitor (this is not just about capacitance and maximum voltage, but things like safety features, peak and sustained maximum currents, temperature ratings....*) you could have bought a serviceable replacement capacitor at an electronics parts supplier (RS, Digikey...) for a very, very competitive price. If you are lucky, the original manufacturers part number remains on the spare part, so you can try to find an identical one via such a supplier. In rare cases, the part sold as a spare could be a modified or specially selected part - manufacturer buys a lot of part XYZ, tests them all to their own specification and throws away (or uses in another application) the parts that do not meet it.
What you are buying with a manufacturer supplied spare part is their knowledge of which specifications on eg a capacitor matter in that appliance design, and choosing the right parts from the market. Another reason for the markup is that the appliance maker, not the capacitor maker, is responsible for having a supply of spares available, so they might well keep a lot of spares in storage that will be useless once the appliance line becomes obsolete and uncommon. And even "the pros" will pay a huge markup here compared to what they'd pay an electronics supplier for some capacitor.
Price politics "against" DIYers might have to do with the expectations of buyers when it comes to returning "defective" parts - a higher likelyhood that an amateur will want a refund on a spare that they themselves damaged trying to install is probably assumed, and the cost for that included in the price.
*DO NOT DO SO unless you are sure of what you are doing, especially if it is about capacitors in mains-connected circuitry. A Rating "120VAC" without further qualifications, for example, would not by a long shot mean the capacitor is suitable for being used here - and capacitors can fail catastrophically.