The sale price falls between what the customer is prepared to pay and cost plus.
(If the cost plus is more than what the customer will accept, it's not worth doing business).
Complete bikes are a highly competitive market, and this drives the price down to very close to cost plus pricing. It's the high volume, low profit part of the business. The accessories and parts are the high profit part that keeps them going.
Bike parts are not competitive. Most bikes sold never get to see a new part except accident damage, and individual parts are relatively cheap, so the consumer cannot save that much by shopping around. Most parts are sold and installed at shops and the labor cost will not change shopping around. Most consumers do not have the skills or desire to install parts themselves, let alone diagnose a fault. Even for the small percentage that replace worn out parts, shopping around is hardly worth the savings (unless you go online and buy on the world-scale market).
On a world scale, the likes of wiggle show just how much profit is in parts, yet they represent a very small percentage of bike parts sold. Most parts are sold and installed at shops. As such, they have little volume buying power and probably pay more for parts than the manufacturers, or pick up the end-of-life parts the manufacturers no longer make and stock. Have a look at wiggle stock - you will not often get exactly what you want - you will get usually something very close - unless your bike is a year old - because they are an 'end of run' outlet shop.
Comparing to computers is not correct. If you look at what's happened, laptops and all-in-ones are a lot cheaper than boxes and the modern PC equivalent of the pre-assembled bike. Try building a laptop or all-in-one from parts and see what it costs. Your "custom built PC" is now the equivalent to that "silly high-end" bike. Years ago, the market for parts for a PC was a very competitive one with many manufacturers.