The long and the short of it is that Nintendo and Valve have correctly understood that videogames are a hit-driven industry, with no single winning formula besides giving the right people the resources they need to publish their concept, like literally all other mass entertainment. How they approach this slightly varies:
-Nintendo's approach is to 1) create games in a wide variety of genres based on interests in the wider mass-culture (e.g. Nintendogs, Wii/Ring Fit, Wii Sports, etc) and 2) reduce barriers to entry for newcomers where possible, in order to cast a wider net
-Valve's approach has been to try to smooth over as many points of friction as possible between creators and customers - even to the point of actively encouraging the blurring between a creator and a customer (i.e. if you want to make and publish a mod they'll happily distribute petabytes of user-created mod content via Steam Workshop for free, and even give you money to integrate that content into the official game if users want it). Despite having serious disadvantages in some areas (for example, most of their users are interfacing with Steam via an OS Valve have no control over), Valve handily outperforms its competitors when it comes to features and discoverability, even trouncing a competitor who literally owns and operates the OS that most of Valve's customers use. It is a miracle of engineering that Valve have made the Steam Deck experience as seamless as it is, given the complexity of the task.
It's no coincidence that for both companies, public shareholders either don't exist or have relatively little power over decision making, which means they have the opportunity to make investments that might not bear fruit for years.
Let's contrast this with Xbox and Sony:
-Outside of their initial xbox live arcade offering and their active courting of Japanese developers in the early/mid 360 days (coincidentally their most successful period), Xbox have largely been reactive rather than proactive - i.e. they see something valuable, and step in and buy it, and then throw money at producing the thing with the expectation of continued success. This has failed for 2 consecutive generations now and has badly diminished their signature franchises like Halo. I have yet to see evidence that this works in a sustainable way - at the end of the day, it's the developers who make a franchise what it is, and if you're primarily buying the IP but are losing (or worse, actively laying off) the developers, then it's quite easy for developers to replicate what they were doing elsewhere. It's not like the raw elements of intellectual property, like the characters and setting of something like Diablo, is that valuable to customers - it's mostly the game design which is the primary appeal, which is not intellectual property and which can easily travel with developers from one company to another. Their other major issue is that their parent company not only doesn't understand the business, but it is also most responsible for sabotaging xbox after its most successful period.
-I think Sony once correctly understood Nintendo's strategy, which is why they commissioned a wide variety of pitched game ideas, including the signature breakout hit of their first 2 console generations, Gran Turismo, which was based on the simple proposal of "driving my car on my TV". Numerous failures during the PS3 years have left large, spectacle-heavy games as their main attraction (Uncharted, God of War, Last of Us), and they have at this point tripled down on the business model of spending constantly expanding budgets on low risk winners. However, as can be seen by the collapse of high budget Disney/Marvel/DC movies, there is no such thing as low risk if customers simply get bored, and locking yourself into the arms race of delivering a constantly escalating spectacle is going to drastically reduce your profit margin. I would also say that unlike Nintendo, they are flippant about both acquiring and shuttering studios without any real forethought besides seeing dollar signs in their eyes. This has resulted in them making absolutely insane purchases (buying Bungie based on the performance of Destiny 1 and 2 was simply insane, the issues at Bungie have been thoroughly documented), while simultaneously penny-pinching numerous studios out of existence, despite their 1st-party software lineup having serious gaps outside of 3rd person action games.
Xbox' only hope is either to bow out and become the largest 3rd party publisher going forward, or if they insist that they can stay in the console market, they need to:
1) completely halt the business practice of enforcing <2 year temp contracts and actually build a permanent employee base - they have massively devalued Halo and Forza as a result of this business practice alone
2) expand their UK operation at Rare and Playground Games and, aside from tentpoles like Sea of Thieves/Forza Horizon, explicitly put them to the task of replicating Nintendo's production model - i.e. spreading resources around a number of smaller budget games in underserved genres that can be delivered in 2-3 years, and see what succeeds
3) Produce at least one hit free to play GAAS game (ideally the next Halo or a Sea of Thieves sequel) where the monetisation is based around gamepass (i.e. if you own gamepass, you always get access to season passes, no matter what platform you're on. If you don't, you pay for each one). I don't think the current gamepass model of rotating singleplayer 3rd party titles actually works - we already know completion rates for these games are low and most users already have some combination of a massive backlog or a couple of gigantic service games they spend most of their time on. I think the only way of growing and sustaining gamepass is to get a couple of big 1st party GAAS games on there, make gamepass a no-brainer option if you plan to play even one of them, and then slowly reduce the 3rd party offering on gamepass over time. Post ABK acquisition Microsoft's 1st-party offering should easily be enough to mostly carry gamepass, provided they learn their lessons.
4) Invest in building a marketing presence and supply chains outside of the US and UK. Whoever has been responsible for Xbox' marketing to date should simply never be used again. The lack of any established presence in international markets has meant that any gains from the 360 era basically evaporated instantly.
Sony are probably locked into their current trajectory until a high profile flop shakes them out of it - but regardless they will continue to reduce the gap between PS and PC releases. Just look at Sony's marketing budgets for the reason why - no sane company will look at those numbers and say "yes, lets continue to spend tens of millions of marketing budget advertising a game to one set of customers only, before arbitrarily relenting later and quietly dumping the game onto a market of about equal size". Sony's advantage is that they have basically won by default due to xbox' mistakes, so will reap the benefit of being the de facto home console in most markets, and thus get support from 99.9% of third parties. In a sane world this would appease shareholders, but it won't, so they will probably react in some way to the fact that almost the entire streaming industry is oriented around Steam/PC primarily, and any current barriers to entry on PC would be destroyed overnight if Valve started selling a TV device.
Sony's other potential issue is that high profile Japanese publishers simply cannot ignore that Nintendo basically owns the Japanese market now, so Japanese 3rd party games may become primarily developed for Switch 2. If that's the case, then any power advantage of PS5 is rendered meaningless, because vast swathes of the market (99% of indies and 99% of Japanese developers) will be delivering the same games to a cheaper device.