It's used because, despite the fact that race doesn't really match with genetic ancestry, it still has impacts on people's lives and health.
For example, a study indicating that "black people in the US are X% more likely to have {some condition}" is useful, even if "black person in the US" doesn't tell much about an individual's ancestry. That's because health conditions are heavily influenced by environmental factors, and someone's race impacts the environmental factors they're exposed to.
This does get complicated, and requires digging deep into the data. Top-level statistics don't indicate root cause, which still needs to be researched. But top-level statistics can indicate that there's a problem that needs to be worked on, which is why medical studies tracking race are still useful.
It’s still correlated enough with ancestry that it can be a useful proxy for health issues related to ancestry—in addition to the environmental factors you pointed out.
For example, a study indicating that "black people in the US are X% more likely to have {some condition}" is useful, even if "black person in the US" doesn't tell much about an individual's ancestry. That's because health conditions are heavily influenced by environmental factors, and someone's race impacts the environmental factors they're exposed to.
This does get complicated, and requires digging deep into the data. Top-level statistics don't indicate root cause, which still needs to be researched. But top-level statistics can indicate that there's a problem that needs to be worked on, which is why medical studies tracking race are still useful.