That doesn't make you a bad person. It makes you a person that should see a professional, about a problem that you need help solving. I hope you make an appointment, so that you can have peace of mind.
I have a nasty voice pop up in the back of my head at random times. I'll be talking to someone nice and that voice pops up saying something vile. I HATE these thoughts but if they're from me, am I secretly a bad person? How do I make this stop?
You probably need to talk to someone professionally qualified to help you. There is no way that you can get a correct answer without knowing more about you and your health. Seek the assistance from someone qualified that can get your whole story. What you are doing now is like asking a doctor for some medicine without an examination.
The only way I can think of offhand to get rid of thoughts you don't want to have is to fill your head with other thoughts, possibly of other things you don't particularly like or want to think about, but thoughts that are hard to get rid of, like remembering images from a really stupid Taylor Swift music video, like "Shake It Off." Anything like that should do the trick.