Im surprised no one got this one yet. Masturbation is a sin from a biblical basis based on the story of Onan. He was supposed to marry his brothers wife to give her children after his brother died, instead he spilled his seed on the ground and disobeyed god. So short answer: because a lot of early jewish law was designed to make sure they multiplied and some guy decided fucking his brothers widow was too creepy.
This only explains why they would think that male masturbation is a sin though, and when they discourage women from doing it its probably more about not harboring any lustful or impure thoughts, or similarly saying youre not allowed to cum unless youre trying to make more christian soldiers. Thats your one n only reward for doing so and if you discovered and took control of your own sexuality we’d have nothing left to hold over you.
So yeah in short who cares? But since you asked thats more or less where it came from. Pun intended.
Sin doesn’t exist....it’s a religious construct! Whether the bible mentions it or not is immaterial and no point in wondering about a god who doesn’t exist either. The reason religions frown on it is because they use it as a means of exercising control. All religions are obsessed with sex and sexual practices....the insistence that priests in the Catholic Church are celibate is just another example of control, even of their own clergy. Repressed sexuality is probably what caused so many of them to molest children,...better that they engaged in masturbation than that.
Sorry but I did not realize agnostics believed in sin. You truly seem concerned about this. I'm hoping you are not riddled with guilt and shame. The answer is simple. Remove the word sin from your entire life. The condition of sin is a construct of human clerics designed to be imposed on ignorant populations as a tool for maintaining their submission and intensify the clerics power.
Religion is a control system just like government. Both were designed by power hungry people to con people into following rules they instituted. Religion uses God to scare people into following their rules with the threat of damnation in the afterlife for disobedience. Government uses police/courts to inflict damage onto those who do not agree with said rules of society which they installed without our personal consent. So the real question that needs to be asked...just who told you that you were a sinner or an outlaw? If you do not cause harm to another...why is something immoral or illegal?