Here’s what the Catechism says
“To form an equitable judgment about the subjects’ moral responsibility and to guide pastoral action, one must take into account the affective immaturity, force of acquired habit, conditions of anxiety or other psychological or social factors that lessen, if not even reduce to a minimum, moral culpability.” Paragraph 2352
Those are a lot of big words. I’ll try to simplify it for you.
A mortal sin is complete rejection of God. It comes when you commit a grave offensive intentionally. That is to say that a mortal sin DOESN’T happen by accident. It isn’t the result of mere human weakness where you’ve been struggling and then stumble into it, fighting yourself along the way. Traditionally we speak of full consent. This means there is no division in your will. You’re engaging in an immoral action without reservation.
Ultimately, if you’re a practicing Catholic, seeking out God’s graces when you can, living a sacramental life with regular confession, then even if you’re falling into grave sins, chances are that you’re not completely morally culpable.
We all have divided hearts. We’re all on a spiritual journey to Heaven where we’re learning to give more and more of our hearts to Christ. So while Protestants see it as a one-time conversion experience, we are sort of in the “I believe. Help my unbelief.” We tend to always have one foot in and one foot out.
The gospel isn’t primarily about the moral law. The moral law is certainly a part of it, but it’s important to understand that God wants to write the law on your heart, to help develop your conscience. Chastity is a virtue you develop over time. It isn’t something you strive to preserve like virginity. It is something that starts out as a seed and grows. You have to nurture that garden it’s growing in.
So the important thing is to understand that masturbation is a sin. Don’t worry about the mortal and venial stuff. Recognize that you shouldn’t want to sin at all. Venial sins shouldn’t be the “Hey I can get away with these ones.” So simply go to confession and do what you can to avoid the sin. Beating yourself up afterward serves no purpose. It won’t help you avoid it in the future. It won’t somehow make up for the fact that you’ve already done it. Realize that the temptation to beat yourself up is a temptation as well. Accept yourself as a human being called to receive grace to become more than what you are, to become holy. This is something God does inside of you. Don’t despair that you are not a saint yet. Don’t fear that God will reject you for not being what he wants to transform you into.