Everyone is racist to some degree. I don't think that is what's going on here though. Most overt racists I've encountered had no shame or embarrassment about being racist. There is an odd thing that happens with some forms of MI including depression, anxiety, and OCD. I think it's called inappropriate or unwanted thoughts. Maybe intrusive thoughts. Thoughts that you don't want... that really aren't yours or are beyond your control. They come unbidden and tend to pass quickly. If it wasn't racial it would be sexual, religious or some other category. Try not to let it cause you extra anxiety. It doesn't mean you are a racist or a terrible person.
Oh and welcome to the site. I hope you like it and find it helpful