I had slavery in mind with the private enterprise comment.
But it's not like businesses are actually run by perfectly rational automatons according to textbook economics. They're run by owners and managers who can be just as racist as the surrounding community, and who can very well prioritize prejudice over a little more profit.
As for Unions, think about it, their major threat is cheap labor from abroad, so the way that they have historically been discriminatory has been in lobbying for anti-immigration and immigration quota (don't know if they still do that as much).
Unclear why you were downvoted. Another example of this was Plessy v. Ferguson where the railroad worked with a civil rights group to bring the case:
>...On June 7, 1892, Plessy bought a first-class ticket at the Press Street Depot and boarded a "Whites Only" car of the East Louisiana Railroad in New Orleans, Louisiana, bound for Covington, Louisiana.[11] The railroad company, which had opposed the law on the grounds that it would require the purchase of more railcars, had been previously informed of Plessy's racial lineage, and the intent to challenge the law.
The USA has been pretty racist in discriminatory, and I think it's disingenuous to single out unions for that history. I mean, who instituted Jim Crow and profited from slavery? White voters, government officials, and private enterprise. Unions were definitely not leading that.