Angelina
The issue of religion and masturbation is quite a complicated topic. There is basically nothing in the Bible about this except for Onan's story, which is ambiguous. Traditionally interpreted as a condemnation of masturbation, nowadays it is rather assumed that it describes interrupted intercourse. In general, Jewish sexual ethics tended to become radicalized - what was once allowed (polygamy) later became forbidden. Many factors could have influenced this, especially relations with the nations surrounding the Jews, from which they wanted to distinguish themselves, or vice versa, from which they drew some ideas. Christianity took over much of the Jewish approach to sex, contrasting it with Roman sexual promiscuity. Interestingly, masturbation itself was not a major problem until the 18th century - Christian churches condemned it as a violation of the commandment "thou shall not commit adultery" (any form of sexual expression other than between a man and a woman within marriage was considered such a violation), but in fact few people except for the clergy, this problem was of concern, especially in Catholic countries where the gap between the official teaching of the Church and practice was huge. The paradox is that it was only the Age of Enlightenment (quite strongly rejecting religion) that made masturbation a kind of secular sin against health, which later all churches eagerly used to support their teaching.