Games sold on the consoles have around a 15 usd flat royalty for big titles, not sure how that affected low cost games at the time. The 360 needed 5 games to brake even, but I believe they had an attach rate of around 3 at launch and that was unreal and unexpected at the time.
It's actually doubtful whether they were really selling at a loss per se even then, most likely the notional loss represented amortizable R&D. Which is a loss on your annual balance sheet but - if you understand your business, can finance the R&D cost affordably and have a steady nerve so as to stick with the plan - this can be profitable eventually. The era of straight up dumping (exporting products for less than their BOM price, which may be illegal in some international trade rules) was last century. In the Sega era it really was possible you'd spend $100 on the actual product, sell it for $80 and figure you'll make up for it on royalties.
This needs to be noted that it’s average as in 5 games per unit sold. So two consoles and 10 games sold to one person. The attach rate is a term related to games sold with the console at time of console purchase.
360 for sure was selling for a loss on cogs, that was rectified with the Xbox one that I believe was 400 cogs for 500 retail. It frustrated a ton of folk because 360 was 300 retail, but this was a clear change to make the console profitable without sales since they were worried people were buying it as a media device, hence the media focus of the Xbox one.
Just to be clear they managed to reduce the cogs with the Xbox 360 small and sold them at a profit without license sales.