It depends on whether we are talking about the short term or long term. In the short term the PS4 victory competely overshadows the Vita defeat. Profit margins are much higher in the home console market. Financially, Sony is doing extremely well right now.
In the long term, the Vita defeat is going to be a bigger deal. The Switch is the type of innovation that is going to transform the gaming market. In a few years (say, in generation 10) hybrid systems are going to be the standard for gaming hardware, and that means Nintendo is going to be doing extremely well for a while. Sony is going to be playing catch up once they realize that they need a hybrid system to compete.
However, Nintendo would have never "gotten away with" the Switch if they hadn't kicked Sony out of the handheld market first. $300 at launch is cheap for a home system, but it is very pricey for a handheld. Really even $200 for the Lite model is still on the pricey side. If Sony had a "Vita 2" priced at $150-$200, then Switch would have had a much harder time taking off, and also some of the Switch's third party games would have gone to Vita 2. It would have made life harder for Nintendo all around.
But the reality is that Nintendo Switch has a monopoly on the handheld market and it is appealing to home console gamers too. It's so successful that hybrid is going to eventually become the hardware standard for consoles. But Nintendo would have had a much harder road with Sony was still selling a handheld.
You're right, the vita's failure is part of the Switch success, having the handheld market to its own, Nintendo has a strong advantage.