Partially because frame only options are usually the top of the range frame with bolt through axles, expensive shocks, etc.
When you buy a compete bike the basic saddle, seatpost, bars, stem are probably costing them peanuts. Less headline parts are probably also cheaper than you’d consider (headsets, hubs, rims, tyres, grips). Then a deore groupset with an XT mech looks expensive in the showroom. And some parts are OEM only, like Fox forks, you could buy the £1000 aftermarket versions yourself, but the bike probably comes with a model with last years castings, simpler dampers and a coil spring and costs them £200.
And thirdly, it just makes the base model look good value (the model that people looking for good value are probably going to be most interested in)