Wii U was sold at a loss.
That is them projecting it would be sold at a loss at first. That doesn't mean it was sold at a loss its whole life, let alone most of it. Parts get cheaper over time/with demand. That being said, the 3ds was absolutely the reason Nintendo had profits in the 3ds/Wii U years.