Don't buy from key resellers.
Don't buy from regions you don't reside in, just to take advantage of regional pricing.
Nintendo should just revoke access though. Banning entire Switches is ridiculously nuclear and anti-consumer.
Don't buy keycodes from grey markets that allow users of said market to sell to you.
While, as a game dev, I fully agree with the sentiment (and I'm trying to spread the word about resellers so that they're forced to at least allow devs to opt out their games from their store), the punishment should also match the crime. Losing access to all of your games because you bought what you perhaps misguidedly thought was a perfectly legal game code is far too harsh.