There could be something that checks the list of installed titles on your system.
If it detects Pokemon Sun or Pokemon Moon on the system, you get banned.
They could have something set up that checks the installed games on your system (excluding any game cart you have inserted) and then checks your Nintendo e-shop account, and if there is a mis-match, the ban is issued.
It has nothing to do with not going online in-game, it may be involved with just having the game installed and then having your 3DS connect to the internet, period.
I never accessed any online feature. I do have over 80 hours of gameplay on my save for Pokemon Moon. Who knows what caused it? Who cares at this point. I never played games online that much anyway. If I want to play Sun and Moon online so darn badly, I'd look into removing the ban using my currently un-banned old 3DS.
I'm puzzled over this as much as everyone else is, there have been a number of users on this thread that have stated that they never connected online.
To the users affected that never connected online: Do you have a NNID? What was your Friend Settings for the 3DS Set to? Did your system connect to the internet on the home menu at any time while you had Pokemon Sun or Pokemon Moon installed?