Yes, there are a lot of people that have found themselves in your predicament. If it is a person that you believe you shouldn’t be in love with, it is most likely because you either know that the person is bad for you or that they are not available to you.
You have to protect yourself in situations like this. Allowing yourself to continue thinking about the person or fantasizing about them makes you more emotionally attached. You should do everything in your power to redirect your thoughts to something else whenever this person comes to mind.
You can replace thoughts about the person with thoughts about a hobby, place, thing, etc. Also avoid being around this person or people that this person may know. This way, you are not tempted to look at the person or make conversation with them, and you are able to avoid hearing about the person from people that may know him.
Do this over a sustained period of time and you will find yourself no longer as emotionally attached to him, which will allow you to move forward with your life.