Minecraft can actually be a bit touchy. I used to always have problems with the PS3 version in college, since the network was somewhat restricted. I would be able to connect with some friends, but not others, unless I used a mobile hotspot instead.
If ya have any other games on the Switch that has online play, you should test that as well to see if it gives you issues as well. If not, you may want to Google connection issues with the console version of Minecraft