20 years old and can’t get hard with my girlfriend

I suppose it’s easier to get help with my issue if you guys understand the whole story so bear with me. The first time I was going to have sex was when I was 17 with my ex girlfriend, I couldn’t get hard but since this was the first time it happened I thought it was a one off. The next time we tried to have sex I was cuddling next to her with an erection then 5 minutes later, nothing. After that the next time I attempted sex was a year later and it did work that time however I was drunk and lasted a short time. Fast forward, I’m 20 years old with an amazing and extremely attractive girlfriend however I’ve encountered the same issues. The first couple of times I was cuddling next to her I had an erection however it didn’t feel like the right moment due to us chatting or watching something important. I decided to wait a few moments before initiating sex, however my erection went and I couldn’t get it back. I’m still releasing pre-cum at this point (a lot of it) but I have no erection so I give up. After this happened a couple times I bought viagra and it worked but I didn’t want to rely on it at a young age so after the pack finished i attempted again naturally. I did have sex a fair few times without viagra and it was really enjoyable, however I did lose my erection a couple times but I managed to get it back relatively quickly. Recently I’ve started to have the same problems where I can’t get an erection (even though I’m mentally turned on) and it’s killing me. I’m 20 years old, work out several times a week, take my vitamins (including vitamin D and magnesium) and eat relatively healthy. I have noticed I don’t wake up with morning wood but I can masturbate normally without porn. I used to masturbate in the prone position (when you grind against the bed) but I searched it up and saw it cause a few people problems so I stopped and haven’t done that for a few months. I started the mojo course recently and although I do feel like it’s helping I’m still struggling to get an erection, what should I do?