I have had this too, during the time I was at the hospital for my depression.
During that time I met a woman and in the week-ends we were allowed to go home, so I slept at her place then. She was my girlfriend by the way.
Anyways, the first time we made love was over quickly, I hadn’t had sex for over 2 years so I came after a couple of minutes.
But during that relationship I had this problem several times (at least 10 times) while making love to her. No matter what or how, I just couldn’t come.
We even got to the point of no return (for both her and me) but when we were about to cum, it magically disappeared and only she would come.
My thought is that it’s something in your head, and it could be that you don’t even know what/how/why etc..
In my case it could have been from anti-depressants, but I doubt it, because I always had an erection when we got close to each other.
And unlike you, I could NOT get an erection while helping myself. If my girlfriend wasn’t there, there’s no way it would get up.
You will probably find my opinion stupid or something, but try not to think about it.