I suspect there are multiple things going on. As others have said, there is research that suggests people from different ethnicities pay less or more attention to particular features when recognising people. So, if you're white, you may pay particular attention to eye and hair colour. If you're black, you may pay attention to skin tone. Article here that explains in more depth.
Alongside this, in general, it's easier to remember things that you are familiar with. So people generally find it easier to remember a familiar name than one they have never heard before. In the first situation, they only have to remember the name and link it to the person. In the second, they also have to remember unfamiliar sounds, so the cognitive load is larger. So if you have a teacher who is not familiar with names from different cultures, they may struggle.
And in addition, you will have individual variance between people ability to recognise faces and recognise names which could also be a factor. I haven't taught for a while, but when I did I taught about 300 kids each week. I learnt most kids names, but in every class there were 2 or 3 kids I constantly confused. (All white). I've no idea why. I don't think I'm great with faces in general and my dd has a great deal of problems with this - she can't recognise people who have been in her class for the last 5 years and can't follow TV programs because she can't recognise the different characters.
And you may also have some people who are just twatty and make a point of saying things like "everyone from X group looks the same". But I suspect most teachers who have difficulty are probably mortified instead of unapologetic.