One such reason is that you have unfinished business with them, and although they have treated you badly, you still wish to be friends and so are unable to stop thinking about them. Whether it is because you feel as if you can’t trust them or because in return for treating you badly, you may have said or done things to them that you regret.
Another reason you may be unable to stop thinking about someone is that, you love them very much, whether it be a parent a sibling or a partner.
Everyone does things that hurt someone they really love and care about at some time, but they never mean to do it as no one is perfect. And it can be difficult to stop thinking about that person, because you love them and you want everything to be ok between you as you may worry that it was your fault. On the other hand you may not be able to stop thinking about them because what they did was so hurtful to you and it is only made worse by that person being someone that you love and trust.
A final reason that you may not be able to stop thinking about someone is that the thing that has been done to you was so terrible that you are unable to get it out of your head. Some people block out a really bad event by suppressing them in their mind, but it is much healthier to face what has been done as you will then be able to move on from that. Once you grasp the reason for your focus on that person, you will be able to understand it and even grow from it.