There is also a world of difference between "almost won" and "3rd place by a slim margin". But we can just agree to disagree on this point. They have been on a decline in console sales since their peak with 360, that's for sure. They've essentially had a single outlier of a generation when it comes to console sales growth or market share. So it was almost always like this. But that points back at the question of Xbox's future, and what Xbox is defined by. If it's just a console, they are in trouble.
Here we can see, that since 2017 at least, they've been increasing in revenue. I'm sure someone will chime in with caveats about acquisitions, but they didn't buy other companies to not make money from them. They are increasing in revenue. This latest holiday was the
second highest in terms of profitability, despite a revenue decrease for that quarter. So an increase in revenue and an increase in profitability, despite a decrease in console install base. I think we can all see why they are pushing services like Gamepass, and publishing titles on every platform around - because it makes money.