I only can stay hard if i focus on the situation

Hi, so, this year was my first time having sex this year, which im kinda proud of, but i did have a lot of issues, at first it wouldnt get hard at all, then i was able to for som reason, then came during prelminaries, if im not the one being stimulated, i dont get it up. And when its finally up and rock hard, i begin the penetration but boom go soft as soon as the thought comes to mind. I assume its my negative self talk that keeps doubting me but what annoys me the most is the fact that i can only get it up if i focus on the situation and dont think about anything else, any tips?