Based on what you said, it seems that you have the kind of erection problems that come and go, sometimes you can have erections and at other times, you can't, which can be caused by different cases such as stress, anxiety, fatigue, or habits. It is said that this is the reason for concern, especially in your age. To deal with this matter, you should consider sticking to a diet rich in nutrients, getting enough physical exercise, and ensuring enough rest. Stress control, through relaxation exercises, might be helpful as well. However, in case it doesn't get any better or gets worse, I would suggest you seek help from a physician or sexologist who can help you get the best medical treatment and support.