You are possibly suffering from OCD, a form of anxiety disorder. You would benefit from consulting a psychiatrist for medications for the same. I understand these thoughts are extremely distressing and intruding.
Next Steps
First of all, please consult a psychiatrist. Thereafter psychotherapeutic techniques like CBT will be helpful for you.