As is represented by drawings on caves, depictions on silk paper and other means of visual representation antiquity viewed and acted on masturbation in a different way than most present day societies might expect. Antiquity didn't view masturbation-apparently-as a shameful, sinful act that only the depraved indulged in but rather a natural, normal expression of sexuality.
Studies done in more modern times have pointed to the efficacy in promoting both mental as well as physical health of indulging in a bit of masturbation as a means of relaxation and releasing of sexual frustration. Frustration of any kind is, of course, detrimental so avoidance and/or prevention is certainly a logical course of action to follow.
Sexual frustration is a condition that many have come to believe is an inevitable stricture of life given the societal decrees regarding masturbation. Antiquity clearly had other ideas and acted upon them.
Many societies associated sex and the sexual act, whether with someone else or by themselves, with nature's abundance. Since those of antiquity were much more closely associated with nature and much more likely to feel immediate negative consequences of lean times than those of more modern times anything that could be done to encourage this abundance was deemed a more than appropriate pursuit. Most of the population of antiquity seems to have equated human sexuality and by default masturbation with abundance in nature.
Egyptians of antiquity felt that when the act of masturbation was performed by a god it became an act of creativity or magic. Both of which were seen in highly positive lights. There is a creationist myth that tells how the god Atum created the Universe by masturbating to ejaculation. Talk about releasing sexual frustration.
The Greeks of antiquity felt that masturbation was a normal healthy manifestation of sexuality. They felt that rather than being part of myth and legend it was a reasonable way of engaging in sexual relaxation along with what society today considers more acceptable means. They considered masturbation to be a way of releasing sexual frustration thus avoiding any conceivable negative results of suffering from such a frustration. Male as well as female masturbation is depicted by both these civilizations of antiquity.
These are by no means the only civilizations that expressed their sexuality in ways other than what recent society has deemed appropriate. These people while certainly interested in perpetuation of their species and culture, being perhaps more in tune with the natural course of things, found masturbation to be a highly appropriate course of action to follow.
It wasn't until the times of antiquity were history and a different mindset became prevalent that masturbation was, on a large scale, relegated to the halls of sin. Many religions, most of which are widely practiced today including Catholicism, Mormonisn, Judaism, and Islam view masturbation with a critical eye. Any considering such an act in spite of religious teachings have been cautioned with warnings suggesting that acting on such urges could equate with resulting psychological problems.
Happily it is becoming more widely discussed and the constraints imposed by religious groups in their attempts to control their devotees seem to be waning.