According to the Catechism of the Catholic Church, an act of masturbation in itself is serious matter for sin.
Any mortal sin requires two other elements. They are sufficient freedom (willfulness and consent) and knowledge or awareness. I keep saying it is not always easy to judge how much freedom and consent—or awareness—are present in an act.
But a person may not simply proceed to self-stimulation, saying it is compulsive. As with any sin, he or she needs to struggle and attempt to resist the temptation.
Finally, the teaching authority of the Church in the 1992 Catechism of the Catholic Church says masturbation is an “intrinsically and gravely disordered action.” Using one’s sexual powers outside of intercourse within marriage is disordered. It is self-love rather than love for a spouse and the fruit of married love.