The Japanese animation "Spirited Away" (Sen to Chiharu no Kami Kakushi千と千尋の神隠し) has an interesting character called No-face. He cannot talk and has no face of his own. He has a mask.
Feeding No-face makes him stronger. This is how our thoughts work. Feed your thoughts by thinking them (giving them attention). Then those thoughts themselves become stronger, demanding more and more 'food', in the same way that No-face demands more food.
What you practice grows stronger, and this applies to your thoughts too. We need to consider well the value of those thoughts to not just our feelings but also our well being. Thinking some thoughts makes us feel 'good' (self righteous, smug, content, etc) but those feelings may ultimately bring bad consequences to our well being.
Shifting out attention to thoughts that foster our well being is the antidote. Meditation is the muscle building activity that helps us shift our attention to the thoughts we need to shift them to rather than letting the stronger negative thoughts dominate and consume more of our attention.