You seem to be suffering from performance Anxiety. Due to overthinking about your ability to satisfy your partner or any stress, your performance goes down, because sex is a mind game, needs to be done under relaxed state, not under any pressure or tension.
Next Steps
Whenever you go for sex, tell your partner that you are not going to put your penis inside, you are just going to enjoy foreplay. You can do foreplay for 15- 20 mins, whenever you feel enough confident, you can put it inside
Health Tips
You can do early morning jogging for 15 mins daily
Along with you can do meditation/yoga/pranayam,whichever suits you
You can avoid junk food and take healthy diet
Apart from that you can do deep breathing,when you have overthinking
Inspirate for 1st 3sec slowly and expirate for 2sec slowly
You can also do reverse counting like 100,99,98,97... And so on
It will make you calm and relax
Do some extra curricular activities
And spend all your time in doing some activities
Do Jacobson relaxation technique
https://www.healthline.com/health/what-is-jacobson-relaxation-technique