When i think to hard about getting an erection, i lose it

I had a bad sexual experience with my ex, where we lost a condom.
Since then i focus too much about keeping an erection and when i do that, i cant keep it.
When i make out with a girl und dont focus on it, it works fine, but the moment it gets in my mind, that i have to worry about keeping the erection, i lose it.

Also the same thing with masturbating, when wanting it too much, it wont stay hard.

Any tips?

I get that. The mind can do a lot of things to the penis. Can you masturbate and finish? I see that it wont stay hard in your comments. When is the last time you were able to stay hard and finish? I am 46 and while I had great erections for 36 years, it started to get strange the last 3 years. No morning wood and hard to keep them during any type of interaction with a girl. Granted, stress, exhaustion, drug and alcohol use can all contribute. Also chronic issues like me, I am a diabetic. Any of that going on? All of it contributes to a tough time with your “member”. Maybe think about those things and see what types of treatments will work for them (meditation, diet, etc). You definitely should be able to masturbate and finish. I think that’s one thing you’d want to bring up to a primary care professional or what have you.

I am type 1 diabetic as well (23 years, diagnosed 3 months ago).
It all started started pretty much since then, because of that i think it is psychological.
No drugs, alcohol, a lot of sports and good diet. Hb1ac is also in good range.
But i am really exhausted and stressed lately because of diabetes diagnosis and a lot of studying.
When i dont get nervous about keeping the erection it stays, yesterday it stayed hard while masturbating.
Seeing a doctor next week.