How does masturbation affect one's mental health?

It's normal. Masturbation is a normal behavior of sexually developed men (95%) and women (89%) and is an element of healthy sexuality for most people. It is not a symptom of mental illness. Ones attitude about it may be unhealthy (e.g., excessive guilt, shame, preoccupation) and a very high frequency (multiple times daily) can indicate a problem.