The success is absolutely amazing considering their strategy was essentially doing the WiiU again but better
Not many companies would have looked at a complete failure like the WiiU and just blamed themselves for bad marketing or execution
it wasn't.
The asymmetric gameplay, the unique interaction between two screens and Miiverse were axed for Switch and the touch controls importance was greatly reduced.
The goal Nintendo set with the WiiU was to reunite the family in the living room and make them interact each other through the unique use of the GamePad (+ wiimotes), it also integrated a self owned forum within the console OS.
WiiU was Nintendo take on a "social" console.
This is a video where Iwata explained well what were Nintendo objectives with WiiU:
https://www.youtube.com/watch?v=9AkPdAWfFjI
The goal Nintendo set with the Switch was to deliver the convenience to play anywhere, anytime and how you want for people that had little time due to a busy life.
To do so they started from one feature that was broken on WiiU (off screen play that only work when close to the console) and made it work by using a modular approach to let the player configurate quickly his play style as he need.
EDIT:
The general strategy is the same between Wii, WiiU and Switch that is to solve some kind of problem by using Nintendo unique integration between hardware and software.
However the result vary wildly based on the problem to solve and the execution.
Wii (and DS) was designed to solve the problem of more inexpert people who were too afraid to play videogame due to the complexity of the game controllers.
The solution was to introduce easier to understand/use input interfaces and making games around them that highlighted the improved approachability.
WiiU was designed to reunite people around the GamePad with game ideas that used the centrality of the GamePad and the interaction between the two different screens available (TV and the one on the GamePad) to deliver fun experiences and to encourage social interaction with a built in within the OS social forum.
Switch was designed with the goal to maximize the chance of a consumer had to play videogames in his spare time or for example to improve the chance to set up a local multiplayer session.