The default keybind to turn shield on and off is X.
Are you sure you aren’t hitting X by accident?
Even if you aren’t in a cockpit, if you are on or near the structure and you hit X by accident it will cycle the shields.
If you think this may be the case then rebind it to something else to prevent this issue. I use Shift+X.