Currently there are no cross-platform play of Terraria on consoles, mostly because the console makers doesn't allow it. Each platform uses it's own network to communicate and doesn't allow other platforms to use theirs. The only exception is Xbox Live which allows both pc and Xbox consoles to connect, and some time ago Microsoft tried to bring Xbox Live connectivity to Nintendo Switch (through the game Cuphead). Nintendo didn't like that.
The only games on console that features cross-platform play (like Rocket League) are the ones that uses dedicated servers (which are quite expensive). The server has separate connections to each network and acts as a conduit between them in a limited fashion (various rules apply).
It's unfortunately unlikely to change anytime soon.
Currently cross-platform play only exists between Mobile Terraria and PC Terraria. You need to use the exact same version content-wise on each platform and the
Mobile Dedicated Server. I haven't used that myself, so there are probably some additional caveats as well.