Publishing history is not the only thing that makes someone “qualified” - there may have been a lot of other factors at play other than their race and their publication record. Did these three even all apply at the same places? Maybe the white man was geographically constrained and the black guy wasn’t. Maybe the black professor’s research was a better fit with what the research university he was employed at was looking for, and could teach the classes they wanted. Maybe the white man bombed the job talk. Or any number of other possible scenarios.
If you look at actual statistical records of hiring and employment in the professoriate, African Americans are employed well beyond their representation in both the general population and in graduate programs - they are actually much less likely to get any tenure-track job (much less a plum position) than white and Asian peers. The same is true for women vs. men.
I’m not saying that some departments aren’t trying to improve their diversity and might like to hire women or African Americans if they can get it, but no top research department is going to take someone they think can’t do research and employ them, potentially for the next 30-40 years, simply because of their race. It damages their reputation and the grant money and prestige that grants and publications bring to the department.
(However, foreign national status can have an impact on hiring - because your department has to sponsor your visa to hire you.)