Yes, worry can make it harder to get or keep an erection by changing both the mental and physical parts of sexual behavior and desire. Your body creates chemicals like cortisol when you're worried, which can make it hard for your reproductive system to work normally.
Psychological stressors like work stress, money fears, relationship issues, or performance anxiety can make it hard to get or keep an erection. These stressors can make you feel tense, anxious, or distracted while you're sexually active. Also, long-term worry can make people do bad things like smoking, drinking too much booze, not eating well, or not exercising, all of which can make ED worse.
Managing stress through deep breathing, meditation, yoga, or other calm methods can help sexual function. So can getting help from a therapist or counselor to deal with the things that cause stress. Better sexual health and general well-being can also be achieved by making self-care a priority, adopting healthy living habits, and talking to your partner about your feelings and concerns.