The camps are divided. The prostate does produce the seminal fluid which transports the sperms. The studies were not conclusive, however one study did show that it can lower the risk. But most other studies didn't show any difference. Some studies even found that some men, specifically younger men, who masturbated more had slightly higher chances of prostate cancer.
Also there can be a difference in masturbation and real sex. The chemical composition of the sperm differs when having sex. There’s no real solid proof that ejaculating more actually causes lower risk of prostate cancer. Lack of sex is not regarded as a cause of prostate cancer.
The main risks are the Age, Family history (BRCA1 and BRCA2 gene mutations, including HOXB13 and DNA mismatch repair genes MMR family -MLH1, MSH2, MSH6, PMS2, and EPCAM, Geography & Race and a condition Prostatic intraepithelial neoplasia (PIN) poses an elevated risk, though PIN itself is not cancer.
