You have to also remember why these cars cost so much.
R&D BMW are at the top with mercedes.
Also the design process of a car is incredible with many thousands of components, out sourcing, cost of raw materials is shooting up, every time a new model comes out all of the tooling must be replaced for suitability and all workers trained. All of BMWs factories are extremely well thought through and all tooling is customised from the robots to the way the cars are produced on the main construction line. The conveyor that takes the car through the process is a 360deg rotary clamp that can be moved a full rotation to help with construction. The tooling for placing engines and gearboxes into the car sit 2mm above the floor and hovers to move with production lines. The process of unique customer cars is fantastic too, where components are driven along by robots. Completely automated tracks using magnets in the floor to tell the robots what direction to take. You also have all the CAD software to design the cars all of that is completely custom to BMW, you have thousands of designers, people on the construction line to pay. Top notch factories that use 65% of energy through renewable or low emission sources like methane from land fill, having its own powerplant.
Because the engine housing is now made from magnesium an extremely costly production process must be used as it is so volatile when it is liquified and comes into contact with oxygen a special injection system is used to reduce the reaction. But saves weight and dissipates heat more effectively so saves you money in fuel. Then the magnesium is encased with aluminium for the cooling system another first. Then you have to cost the amount it costs to ship things half way round the world etc.
People forget how these things are made! You dont just pay for a piece of metal, there are so many factors and 50% of R&D is making things you wouldn't even know about like on the production line. Custom costs.
You dont get the same level of tooling and perfection at places like peugeot renault nissan etc if anything they share the designs to reduce cost most new cars are the same designs but with different skins so they can offer it at much reduced costs.
There will also be one car once in a while that has more troubles than others unfortunately. You dont know how hard those miles were on the car from previous owners.