Some tablets (such as those to help blood pressure) can have the unwanted side effect of causing sexual problems.
If this happens let the clinician know who prescribed them as there may be a different drug that can be prescribed to do the same job without these side effects. Some recreational drugs can make it difficult to have sex. This can include having too much alcohol!
Smoking can also make erectile dysfunction worse as it damages the vessels in the penis.