There's the market and then there's psychology...
The main issue with "the market" is that it's made by people, and people are far from always being rational beings. People psychology drives a lot of decision with are far from being fully rational.
I believe people tend to hire people who are alike them - and I not talk about race or gender - but at the behavioural and lifestyle level. Having to spend a lot of time with the people you have to work for, you select those who will make you "feel well" working with - and they have a good chance to be somewhat alike you.
You can observe it in all people group, and you can also observer it in work group. Look at PR/marketing - are those peole alike the IT groups? No. You're going to meet in the former group much more open people, leaning toward dressing classy (not always achieving it), and often selected also for their physical aspect (a nice young woman works better in PR than an ugly fat old man - because of the behavioural aspects of the intended audience). There's a good chance they will spend time with the same kind of people outside work.
You see it in schools, where group forms based on behaviours, interests, and lifestyle. Children looks for other children somewhat alike them, and who make them "feel good".
Thereby purely rational "market" rules may not apply fully, especially if there is no so big differences at the skills levels to prompt those who select people to clearly steer towards a candidate regardless of everything else.
You can also observe this behaviour depending on who is in charge of selection. HR, management (without an IT background) and IT people could select very differend candidates from the same pool. Each group has different selection criteria, and many of them can be traced back to the behavioural level.
The main issue is that gender and race in our society have a big impact on how people develop their own behaviour and lifestyle. People who are going to refuse some behaviours/lifestyle and prefer others, will have far big problems to be selected into a given social group, and adapt to it, even if they have achieved the same skills. Although it may be also hard to achieve some skills if you refuse some social group lifestyle and behaviours. Try to work as a lawyer if you believe the legal system shoud work like an algorithm (and hate to wear a tie) or in fashion if you think there are only three colors, R, G and B, and you don' really care what to wear each morning.