Erectile dysfunction can have many causes, including physical and psychological factors. Consulting a healthcare provider to determine the underlying cause and appropriate treatment options is important. Maintaining a healthy lifestyle, such as regular exercise, a balanced diet, and stress management, can help improve sexual function and prolong erection.