Erectile dysfunction can occur at any age, but it becomes more common as men get older. While it is more prevalent in men over 40, younger men can also experience ED due to various factors, including stress or underlying health conditions.