Losing erection during intercourse

I’m in my late twenties and recently married. It is my only serious relationship and my only sexual partner. I’ve always had issues with maintaining erection and performance anxiety and it has been a tricky thing for our relationship. I’ve done a lot of work through mojo and speaking about my issues in recent years and I know I can enjoy myself in sex and connect with my wife, and we have had a lot of success and good times. In the past my issue was always staying hard / being hard enough for intercourse. Things have changed recently, we were in a really good period and I felt the best I ever have e.g not worrying about sex and just enjoying the moment.

We suffered a miscarriage a few months ago and this has affected me. My drive dipped and I have put pressure on myself as my wife has wanted more sex and more closeness. My issue now is I can get hard and start intercourse, but now more often than not I lose my erection and can’t reach climax - I don’t know if I am just not enjoying it as much or have just got into a bad cycle and can’t break out of it, or something else. It’s really getting to me and I feel like back at square one and feeling quite helpless about getting back to a good point with sex.

My wife is generally supportive but is losing patience and hope - we are quite open in talking about it. She wants me to just flip a switch and enjoy the moment and stop letting bad thoughts come into my head. It’s true - I am quite down about life in general and worried about the future and no doubt this is affecting me in bed.

I also work with my wife in quite a stressful job and see her basically all the time and we wonder if that is making it harder to connect in the bedroom.

I just want this to be something that isn’t on my mind all the time - it feels like the story of my life and I can’t think about anything else. I am very confused and worried about the fact I am now losing my erection in intercourse, this was never an issue in the past and I always enjoyed intercourse once we started it. Appreciate any thoughts or help guys out there might have - thanks!