I think it's simple, they've always made great games at consoles that are always at affordable prices, while making hardware that stands out and is different from everyone else.
Looking back at all the other console makers in history that have failed or have been forced out like Sega, Atari, even one off consoles like the Panasonic 3DO, Phillips CDI, Tiger Gamecom, Nokia N-Gage. They all have many commonalities that led to their demise.
Many of them failed to have great games or any exclusive great games you cant get anywhere else. Games are the most important things to a console. Stuff like the Panasonic 3DO, Phillips CDI, Nokia N-gage, amd even stuff like the Atari Jaguar focused too much on having the best and greatest hardware while forgetting the fundamental thing that makes video games appealing, fun software, and those consoles lacked many of it, at best they mostly got limited 3rd party ports gamers could get on better systems or exclusives that just weren't appealing.
Nintendo of course hasn't ever been like that, their games since the NES have always been nothing but top notch and stuff you can't find on other platforms, and soon their great games developed such a legacy that people would continue to want to go back to them cause they trust their games will be great without hesitation. For other companies its more difficult to do that and build that trust & legacy and make games great enough for 40+ years for people to trust spending 100+$ on a console. I think Nintendo also benefited from lack of competition when they entered the gaming market in 1985 coming straight off the video game crash of 1983 where they were the only legit option for many years for people to first experience those games, now I feel like it'll be harder to pull off with how much competition their is now in the industry, but Nintendo despite the competition built that trust strong enough to where its still able to standout amongst the competition in terms of games.
Another common thing I've seen failed gaming companies do far too often is overpricing their consoles. Pretty much since the birth of video games their was always a huge obsession with graphics and performance, with many people equating more powerful hardware as objectively more appealing as humans are naturally drawn to beautiful graphics that looked advanced. This obsession unfortunately for many companies was too strong to the point where all theyd focus on is having the most powerful console ever, thinking it'll make them the most appealing over everything else, but as demonstrated many times in the industry, it doesnt work that way especially when it comes at a cost of a high price point.
Stuff like the Atari Jaguar, Sega Saturn, PS3, Panasonic 3DO, and others focused way too much of specs at a high price which made it very unappealing to consumers no matter how powerful it was, we like to think graphics are big in video games but legitimately consumers care more about playing great games at a reasonable price. In fact the most powerful console of the gen never won a "console war" since the SNES in 1991, and the SNES winning had nothing to do with specs, it was affordable enough with great games the others couldn't offer.
This is one thing id give Nintendo a ton of credit for ever since their birth but more especially today, they've never obsessed too much about being the highest performing system and always knew that great games at a good price point is the best way to appeal to consumers, they realize games draw people to a system, not CPU cores. This has allowed their consoles to always be reasonably priced enough to be successful enough.
Part of the reason why Sega failed is that they were always too obsessed with being the top dog hardware wise, which is why they overly panicked releasing a bunch of unnecessary accessories and consoles in response to literally every new console that released that wasn't even a threat like the Atari Jaguar, that was unsustainable to support and be successful like the Sega CD, Sega 32x, Sega Saturn, ect... This hurt consumer trust and made them unaffordable with stuff like the Saturn.
3. I think another thing to that made Nintendo so successful is making hardware stand out enough to where theyre in a market of their own. Not only do you have great exclusive games on their platform, but you also have a console that is unique and can't be replaced by another like the Switch concept or Wii. Making them appealing as another console option.
Also, they're smart with their money. They pride themselves on saving money and selling consoles/games at reasonable profit margins. While this sounds like an easy thing to do, it isnt for many companies. Companies sometimes would make hardware too expensive to be profitable or invest in things that aren't reasonable, for example like the original Xbox being too expensive hardware wise making Microsoft lose 4 billion dollars. Or Sega with the Dreamcast overly spending on games like Shemue 3 and console sales promotions. Nintendo doesnt do this.