These are called intrusive thoughts, and everyone has them; some people just have more of them. It's when they become constant and distracting that it becomes a real problem. After all, you're allowed to think about whatever you want.
They come from the primitive part of your mind, commonly...