That’s because on the Switch they figured out how to bind online sessions to digital certificates unique per game copy signed by Nintendo themselves. This way “copied” games can’t get online without being detected.
The 3DS didn’t have any of those checks so you could actually play online with pirated games.