I wouldn't say the 3DS version was the primary product considering it lacks many features that are in the Wii U version.
Well, Nintendo treated it as the primary version - the duo have always been promoted as "Super Smash Bros. for Nintendo 3DS & Wii U" and not the other way around, it was released first, it's had far more promotion in general, and it also has many features that Smash Wii U itself lacks, some of which are a lot better than what Smash Wii U offers - such as Smash Run instead of the execrable Smash Tour, and a Challenge board that was much less unreasonable than Smash Wii U's. One can also argue that the lack of facilities that can be misused to send rude messages in Smash 3DS is a superior feature to Smash Wii U, too.
Moreover, Smash Wii U contains a number of misfeatures and inconsistencies (particularly in terms of the menus and what can and can't be used with the Wii U GamePad, such as some features, like name-inputs, but not other instances of the exact same feature in a different location, being touch-controlled) that were actually handled correctly in Smash 3DS - it felt a lot more rushed (and I'm sure we can both agree that both versions were rushed as it is
).
I meant in terms of the restrictions brought in for the development team. Time, space, and power was in short supply while making the 3DS version this the reason we're missing out on multiple features that would have been included otherwise.
Oh, it definitely brought in some restrictions, but the majority would never have noticed that the features were there had Smash 3DS not existed, since they weren't going to buy Smash Wii U anyway (for me, Smash 3DS was the only reason that I bought Smash Wii U, but I didn't find Smash Wii U as good).
That's an interesting theory but I don't think the port from the 3DS to Wii U would be as smooth as you're making it out to be. Especially not as easy as it will be to theoretically port the game from Wii U to Switch. With the whole fact that the 3DS's resolution is a fraction of the Wii U some deep development had to go in to, at least, updating the models between the two games.
Smash Wii U drops the level-of-detail on models for 8 Man Smash as it is - as far as I can tell, it actually uses the same cuts as Smash 3DS does, there (the quickest example is Wii Fit Trainer's "thumbs-up" win-pose - the thumb is bent oddly in Smash 3DS and Smash Wii U's 8 Man Smash). I'm fairly sure it's not too difficult to drop some detail in order to use the same models across both games - I'm pretty sure that's what was done, even, looking at 8 Man Smash.
EDIT: Since the engine appears to be designed for this (it wouldn't've been possible to release the games as they were, otherwise), I imagine they would've just defined different compile-time conditions when building for the two pieces of hardware concerned.
As for porting from the Wii U to the Switch, the Wii U uses PowerPC for its architecture, whereas the 3DS and the Switch both use ARM, and moving from one ARM revision to another is, as far as I know, usually going to be the easier option. That said, the engine was self-evidently designed for easy porting in the first place - that's why the engine was movable between the 3DS and the Wii U so quickly, allowing for the two games to be developed more-or-less side-by-side, with the primary product being finished and released first, and the secondary one showing up within only a matter of months afterward.