Accept it. Buddist believe whatever arises in consiousness just watch this thought do not feel guilty or judgmental - by just watching your thought ego feels ashamed and eventually the thoughts will shift. In energy by watching you will realize these might not be your thoughts eventually. So the first step to attain peace is to just watch our thoughts.
Positive thoughts. For every negative thought, force yourself to counter it with a positive thought / affirmation. There are prescription medications that can sometimes help obsessive / intrusive negative thoughts and meditation can sometimes be helpful (though difficult to do); but i think that i would want to suggest that you engage in some form of aerobic exercise to give yourself release and relief. Good luck.
Cause or context? Periodic negative thoughts are "our lot in life" - but if it is very distressing, for example, disrupting sleep, your daily routine, or prompting self-medication with substances like alcohol, consider formal psychiatric evaluation. Thought stopping - visualizing a large red stop sign, and shouting to yourself "stop" - can also help. Intentional distraction can disrupt rumination as well.
Good book. Buy and read the book: stop obsessing by edna foa. Good luck.