@Symbeline Game collection has a huge part of it, though. Virtually all consoles are sold at a lost for a significant portion of their lifespan. The Xbox 360 hardware only became profitable in (if I remember correctly) late 2008, 3 years after it was released. The profit margins come mostly from software sales. However, the portable gaming market is generally a higher margin than consoles (which have to be cutting edge).
Computer hardware improves at a very rapid rate. The Xbox 360 release was the first in recent memory in which a gaming console outpaced anything available on PC. The GPU was a generation ahead of anything on the PC and the CPU was no joke, either. It was faster than an, at the time, top of the line gaming PC, which would have run in excess of $1000 (barring unnecessary amounts of RAM or SLI GPUs), all in a portable little box for $300. That’s the price point of the market, and the console manufacturers have to keep it around here to push these devices into households.
If my memory serves me, the Xbox 360 was initially being sold at a $200 loss (PlayStation 3 was much worse to that end). Microsoft profited something like $25 per title sold, so gamers had to buy a pile of games in order to bring in a profit for the company. The average attach rate was only ~3.5 titles, which in some cases brought in a profit. However, die hard fans will often own more than enough to bring in a profit, enough to almost bring the console to equilibrium, although the Xbox division operated in the red for a long time after the 360 release. Once the 360 hardware became profitable to produce, combined with game profits, the Xbox division of Microsoft actually started grossing profits for the first time since it was started in the late 90s.
Since the industry does and always has worked this way, it’s no shocker than Microsoft stayed in and Sega gave up—Microsoft has deep enough pockets to run the Xbox division in the red… forever, pretty much. The company’s other products are a cash cow with insane profit margins. Sega and Nintendo have no such luxury.