Sorry to hear that. Since you gave us so little info to go on, my response will be broad.
Many things affect this in men of course.
Diet, exercise. Stress, hydration levels, feeling under the weather, smoking, drugs, alcohol.
Not sure if some of those were in play for you but since you gave us so little, I’d be remiss not to at least mention and bring them up.
Being relaxed and comfortable is very important too for men and their erections. If they are nervous, for whatever reason, that may affect this.
The old getting it into your head affects this too. You’re not alone there. Many men worry about this happening and it does more times when a man is worried that this will happen ahead of time, during sex play etc.
Being that it happened, you’ll likely worry about it and when/if the next sex play time comes with him, it will likely be on your mind ahead of time and that won’t help.
If possible, talk to him about this. If you’re able to engage in sex with him, then you should be OK talking to him about this. Try talking to him when you’re not going to have sex immediately afterwards.
Hopefully doing that will help to less the tension and worry you have about this. Try to be relaxed, comfortable and such before the next time and having a chat with him is one thing that could help you in this regard.
And when that next time occurs, don’t be rushed, don’t think gloom and doom if you’re not erect seconds or a minute in. Relax and enjoy the present with him.
As long as you’re healthy, this is likely an issue between your ears.
Back to not worrying about it if you’re not erect right away.
“remove the pressure of penetration and shift the focus to non-goal-oriented intimacy, like touching or kissing. By removing the pass/fail mindset, men can lower stress hormones that restrict blood flow, naturally allowing erections to return”
“Practice Sensate Focus: This therapy technique involves taking turns giving and receiving non-genital touch with zero expectation of an erection or intercourse. It retrains the brain to enjoy physical sensation rather than constantly self-monitoring.”
Slowing down, breathing, relaxing, being present in the moment all help. Like it says above, don’t “constantly self monitor” about this, which I call being in your head about this.
“Communicate Openly: Discuss your anxiety with your partner outside the bedroom. Setting realistic expectations and establishing that intimacy does not always require penetration relieves stress.”
I already mentioned this one above. Discuss this, when not having sex with your partner. That will help too.
Good luck to you.