It is possible that frequent ejaculation reduces the risk for prostate cancer (https://www.healthline.com/health/prostate-cancer/ejaculation-prostate-cancer#risk-factors3). If that was found to be conclusively true (or maybe just due to the possibility of preventing a disease) does that permit masturbation as a form of pikuach nefesh/guarding your soul dilengtly?
Even if this study would be true, it would in not permit masturbation at all.
Pikuach nefesh does not mean that anything that might be conductive to our health is automatically permitted. Otherwise the torah would not have forbidden us to eat clams, as clams are high in many vitamins and minerals, and therefore we are “commanded” to eat them in order to keep up out health! This is not true. The only time we may violate a negative biblical prohibition, is when a person’s life is actually in danger and the remedy to save the person’s life would only be possible by violating the prohibition. Only then do we say that we may violate a torah prohibition. For example a Jewish surgeon to give someone an operation to save someone’s life may be performed even on shabbos. However, if the operation could be done on Friday or Sunday, it may not be done on Shabbos. Aside from that it must be conclusively true, and proven. A person that is concerned with guarding his health diligently and reduce his risk of prostate cancer, should choose a low-fat diet, eat more fat from plants than from animals, increase the amount of fruits and vegetables you eat each day, eat fish, and reduce the amount of dairy products you eat each day.
By protecting your body in the way that G-d, the manufacturer of our bodies, recommends, will hopefully help you have a long and healthy life.