Companies are not allowed to discriminate in their hiring. In other words, it is not legal to have affirmative action in a hiring decision (e.g. only hiring female candidates or only hiring black candidates).
To get around this, companies do a couple things to increase the likelihood of hiring an underrepresented person into a role:
1) They will quietly try to fill up their candidate pipelines with people who match the criteria they are looking for to increase the likelihood they wind up hiring a candidate who matches.
2) They will apply the "Rooney Rule" which says at least one person from an underrepresented minority group must be interviewed for a position before a hiring decision can be made.