An NNID can be in three states. It can:
a) Be linked to the console but not signed in
b) Be linked to the console and signed in
c) Be linked to a different console
If you format your console in state a) nothing happens, the NNID is still linked.
If you format your console in state b) it switches to state a)
If you system transfer (as the source console) in state a) OR b) then it will switch to being in state a) or b) on the target console
If you try to create a new NNID in state a) you will be successful (the NNID you just made will be in state b) while the other will remain in state a))
If you try to create a new NNID in state b) you will not be successful, but you can format to make the current NNID be in state a) and then try again and be successful.
If you try to system transfer (as the target console) in state a) you will be successful, and the NNID will remain in state a)
If you try to system transfer (as target console) in state b) you will be unsuccessful, but can format to move the NNID to state a) then try again and be successful.
If you delete an NNID then it won't exist anymore, and you won;t be able to ever sign back in with it again.
To answer your original question: If you format the NNID gets logged out but still linked. You can create a new NNID on the system. If you delete it, it will also be gone but then the game will disappear forever too (if you just format, then you have the option of signing into the old NNID at another time).