Because race is not a biological trait. Age and gender cause reliable differences in how people behave and respond to stimuli. Race is a made up social class system. while ethnicity is biological, it is up to individuals to adhere to ethnic culutural norms that can be used to predict how they respond to ads. In other words, there are no black hormones or organs/parts of brain that develop only on people of specific ethnicities.
But all of that aside, even age and gender should not be used unless that information was explicitly shared by the user to be used for targeted advertising against them.