Cancer can significantly affect sperm quality and fertility in men. Treatments such as chemotherapy, radiation, and certain surgeries can impair sperm production and function. These therapies can lead to temporary or permanent infertility by damaging the testes where sperm is produced, affecting the DNA within sperm, or disrupting the hormonal balance necessary for sperm production.