Though it can be a strange idea to wrap our heads around, we are not our thoughts. Our identity, our unique self is instead defined by what we do with our thoughts. We all have probably had the words, "Wow, it would be really easy to steal that!", or some other immoral variation, come into our heads, seemingly out of nowhere. Even if it is something we would never actually do, we may be tempted to believe that those thoughts represent a true part of our personalities. However many unsavory thoughts show up in our heads unbidden, we are given a choice to welcome those thoughts or to push back against them.
For some, a good technique to help with internalizing this concept is naming that voice in your head. I was so happy to see this recently while watching the movie Luca with my kids. The main character is taught this trick, and he names the voice of fear and shame in his head Bruno. This practice helps us create space between us and, for example, negative self-talk. It's easier to think, "Actually there's no evidence of that," when you don't feel like you're fighting against yourself. Also, it can reduce feelings of shame because you're moving from "I'm a person who thinks thoughts like that," to "I'm a person who is given a choice to accept thoughts like that, but doesn't". If you're having trouble thinking of a name that doesn't belong to someone you know personally, perhaps try a baby naming website to get some ideas. Let me know how it goes in the comments if you try it!
Be aware that though everyone occasionally has thoughts like this, they could be a symptom of mental illness if they are interfering with your everyday life. If you have any questions or concerns, please don't hesitate to talk to a therapist or other healthcare professional. You are not alone, and there are resources available for you.