I don't think there is enough info in your description to evaluate the problem. Is it really due to nail separation or something else? The correlation you mention could be completely coincidental and not causal. I have been playing for decades and can describe a few different fretting hand sensitivities.
(1) If you over practice on the electric (short nail or not) and you are doing a lot of string bending you may pull the finger nail away from the flesh a little. Once that happens it will be harder to practice without pain for a while but once it heals your finger should be tougher and not likely to experience this again unless you (a) stop for a while then start up again or (b) increase your practice time thus causing more stress on the flesh. This type of "injury" may become slightly infected and playing without bending can cause pain.
I must admit, when I was younger that kind of pain felt good so I played through it. I don't think there is any long term damage from that but I couldn't tell you for sure.
(2) One the classical guitar the strings are quite a bit thicker and proper technique has our fretting fingers right up on the tip (about 90 degree angle from the finger board). It can happen that one unfortunately hits a nerve ending in the tip of the finger causing a very "shocking" type of shooting pain through the finger. This can get worse over time. Sometimes a callus develops over the nerve and instead of protecting it the callus stabs the nerve every time your finger touches the string the wrong way. Since this is an example of a nerve getting pressed I'd back off until it gets better. Perhaps don't stop practicing but change the angle of attack for the fretting hand. If you don't find a way to stop this you could cause permanent nerve damage. Perhaps numbness or constant shooting pain (not sure).
(3) Another possibility is dried cracked skin on a callus. Here the string can dig into the wound or just put pressure on it causing pain.
(4) Since you claimed that the nail is always separated from the flesh when it happens it could be that the rest of your finger has become sensitive to touch because of the wound. I can't visualize how as I'm not a doctor, just speculating.
(5) Possible arthritis flare up. I have psoriatic arthritis and when it flares up the fingers become hyper sensitive to any touch. Of course this is usually on the joint and affects bar chords more than playing notes on the tip but I find that there is a sort of non-locality to pain during these flare ups. Playing through arthritis pain is a double edged sword. Movement is good for the joints but overdoing it I suspect could cause joint damage.
It is not a good idea for anyone to tell you would can or should "play through it". That is bad advise without really seeing your hands. If it's a persistent thing you should see a doctor. I share my personal experiences with you in the above comments.
Numbness and shooting pain = stop for a while, or back off, adjust your playing
Stinging wound pain = watch out that it doesn't get worse, avoid techniques that make it worse.
As for not cutting the nails back? I cut mine very far back, every day. I don't want to see a hair thickness of nail beyond the skin. I will push the skin underneath the nail back a little and either cut or file them back. And I don't have the problem you are describing on a regular basis. Only if I cannot manage to practice, the fingers get "soft", then I go back to extreme practice sessions. My fingers are used to it, and yours will be too in time.