I hear the Switch is picky about who tries to connect to the internet. Like, if they are fans of bad Fire Emblem characters, it's likely the console won't connect.
Hey! Dorcas is a GREAT Fire Emblem character!
But more seriously, I had that issue happen to me once. I think it has to do with how IP addresses are assigned. Like your network gives IP X to the Switch, but it goes to sleep and is not connected to the internet, and while it is asleep that IP is assigned to a new device like your phone, then the Switch wakes up and tries to get on the network with the phone's IP and gets an error.
Rebooting fixes the issue, but it really should self resolve. They should be able to fix it in a system update, and also resolve the "freeze" issue in Breath of the Wild which is caused by a network check. those are the biggest issues I see that can be quick-fixed in an a system update.