It comes from many different places and is cross-correlated at many levels. From credit card purchase history to social media to phone location data, across multiple agents and brokers throughout the data market. See: Data Breaches, Crisis and Opportunity (ISBN 978-0-13-450678-4)
Are you implying that US ISP's ask the race of their customers? I've never been asked by AT&T, Comcast, Time Warner, Spectrum, or other ISPs I've used.
I'm not in the business but I'd guess that an ISP can determine with pretty high confidence your race, ethnicity, gender, approximate age and approximate income simply by analyzing your DNS requests. And they probably have a lot more data than DNS.