The bible does not talk about masturbation AT ALL. The only mention (often used by Christians and Jews to back up the prohibition of it) is from a story where El-Shaddai told Onan to get his sister-in-law pregnant after El-Shaddai had killed his brother, Ur.
Genesis 38: 7-10 “And Er, Judah’s firstborn, was wicked in the sight of the LORD; and the LORD slew him. And Judah said unto Onan, Go in unto thy brother’s wife, and marry her, and raise up seed to thy brother. And Onan knew that the seed should not be his; and it came to pass, when he went in unto his brother’s wife, that he spilled it on the ground, lest that he should give seed to his brother. And the thing which he did displeased the LORD: wherefore he slew him also.”
This whole idea of spilling your seed on the ground (and getting killed by a god for doing it) is where the prohibition against masturbation comes from. Problem is, it’s really a prohibition against pullingout, not masturbation. Also, it was only in this one case where El-Shaddai had told Onan to get this woman pregnant.