That sounds super frustrating for you. From what I see in my practice, there are a few things I would consider for you. First of all, how did you and she handle it in that moment? Not achieving an erection every single time you attempt to is actually quite normal, especially as we progress through life. There are a multitude of factors that affect erections that people just don’t think about, such as stress, illness, mental state and some medications. Both of you were possibly embarrassed; I see a lot of females that blame themselves during these moments. Did either of you attempt sex/sex play again after that? Just because you couldn’t achieve an erection right then does not mean it won’t show up later. It also doesn’t mean that you two can’t keep going and do other sensual activities instead.
Based on your report, your girlfriend seems to be avoiding you and sex. Maybe you should bring it up with her. Let her know that it isn’t her, that you find her desirable. Discuss with her the ways that you would like her to respond to you – how your would prefer she handle those moments to make you more comfortable and potentially still sexual/sexually viable. Also talk about other ways that you two can enjoy each other sexually and sensually without it being traditional penetrative sex. There are still plenty of ways to have sex. Or, maybe you could just slow down and continue with foreplay to give yourself a chance to physically catch up.
As for you, if it only happened once I do not think that is a reason to be concerned. And, with all of my clients, I always recommend seeing a doctor just to ensure all the plumbing checks out. I do know this happens far more frequently than anyone lets on, and it is OK. The worst thing you can do for yourself now is to approach every sexual encounter with anxiety or fear driving you. That can absolutely kill your ability to focus and be present to enjoy the encounter; it can also make achieving erection difficult. Don’t psych yourself out!