Well, what happens when someone masturbates? Usually they have some kind of lustful thoughts going on in their minds, and Jesus of course speaks and says that lust in your heart is equivalent to adultery in the Bible.
“Ye have heard that it was said by them of old time, Thou shalt not commit adultery: But I say unto you, That whosoever looketh on a woman to lust after her hath committed adultery with her already in his heart.” Matthew 5:27-28.
Further, sexual pleasure is a good thing, but it’s not just about fun. The whole reason marriage was set up was to produce children. When you separate the life-giving aspect from procreation, it’s selfish. If I am correct, this is what the Church teaches here in the Catechism:
2352 By masturbation is to be understood the deliberate stimulation of the genital organs in order to derive sexual pleasure. "Both the Magisterium of the Church, in the course of a constant tradition, and the moral sense of the faithful have been in no doubt and have firmly maintained that masturbation is an intrinsically and gravely disordered action."137 “The deliberate use of the sexual faculty, for whatever reason, outside of marriage is essentially contrary to its purpose.” For here sexual pleasure is sought outside of "the sexual relationship which is demanded by the moral order and in which the total meaning of mutual self-giving and human procreation in the context of true love is achieved."138
And on a personal note that you might not want to hear, I have masturbated before once or twice. It’s not that great, at least it wasn’t for me. I felt sadder than before, since it seemed like I was resorting to this rather than being with someone like I’d always wanted. I think perhaps this might have been an inkling of what God has written on our hearts manifesting itself in my guilt.
I hope this helped.