Disparate treatment on the basis of protected and usually immutable characteristics, is literally illegal, all the sort of mental gymnastics do not matter, that's literally what the law is.
> the Justice Department secured a settlement agreement with Meta (formerly Facebook) in February 2025, alleging that Meta’s ad delivery system used machine-learning algorithms relying on Fair Housing Act (FHA)-protected characteristics such as race, national origin, and sex to determine who saw housing ads
Furthermore, you seem to be conflating different meanings of the word "advertisement" where the one you've chosen to support your point is a broad meaning that would seem to make Barbie commercials that feature only girls illegal (which is obviously not the case).