Restoring a NAND backup can in theory PREVENT a ban. But if you get banned then that's it, there's no going back
no, it can not. The reason it can not, sincei know that is your follow up, is because there is a unique "cert" or code , whatever you wanna call it that your console has, that is obtained when logging onto nintendo servers. if you were to copy your NAND, your nand still has the same information so if you got banned, your backups cert would also be banned as they are the same.
Technically, both of these are correct. But I'm going to elaborate a little because to a n00b they might sound contradictory to each other.
Like @Asura66 said, yes, you can restore a NAND backup to prevent a ban, but this is a little more complicated than it sounds. Basically, to be safe you have to turn on airplane mode and make a NAND backup before using any CFW or homebrew whatsoever. This is called a "clean" NAND backup.
Then, use all the CFW/homebrew you want, making sure to keep your Switch offline the entire time.
When you decide you want to go online again, you have to restore the clean NAND backup. Then you can play online, but don't use any CFW or homebrew.
When you're done playing online, and want to use CFW/Homebrew, repeat from the beginning, and make sure you make a new "clean" NAND backup every time.
Wash, rinse, repeat. Basically, we're trying to avoid Nintendo ever seeing the Switch go online with a "tainted" NAND. If you screw up, and Nintendo sees your Switch online with traces of CFW or homebrew, you could get banned, and there's nothing you can do about it, regardless of your NAND backup.
Backing up or restoring your NAND takes a long time, so this can be a bit of a pain. Once someone implements a proper EmuNAND (no, TX's implementation doesn't count), then it will be easier to switch between a "stock" Switch and one running CFW. It's also possible that some time in the future a CFW might support injecting the cert from one Switch on another Switch. This could open up a market for people to sell "private certificates" like we saw previously in the 3DS hacking scene.