You’re announcing your virtues
You’re really enjoying not just telling others how much your friend messed up, but also giving examples of times you were put in the same situation, and you handled it much better. This mistake your friend made really just set the stage for you to boast about how you have handled the same situation with absolute precision in the past. It’s basically allowing you to humblebrag. So if, for example, you feel your friend flirted with your boyfriend, you talk about how another friend’s boyfriend once flirted with you. You immediately shut him down, gave him an impressive speech about morality, and reported him to his girlfriend. You love to tell this story.