I can -sort of- relate. I've never had the desire to transition go away, however, back when I still had testosterone ruining my body and mind, I lived something similar.
I felt incredibly awful each time I masturbated, and every time I managed some time without doing it (and that wasn't so often, since most of the time the artificial, unwanted arousal was stronger than me), I felt a little better. Only to have it crash down extremely bad when I did it again.
It might be that masturbating makes testosterone increase, making you feel worse because you have even more of the product in you, whilst normally, the amount you have is tolerable. Or it might be a psychological effect. Something like, each time your masturbate, you're violently reminded of everything you hate about yourself.
Or it might be something else, entirely. If I were you, I'd see a therapist. I've given hypotheses, but guessing is risky in a hard to understand situation like this. A sexologist, perhaps, if your therapist isn't so comfortable with discussing such private issues in depth.