Credit rating agencies (experian, equifax, trans union) collect all the data whenever you apply for a credit card, and then re-sell it to other businesses -- this is the data that experian sells with many of its demographic products, for example. They also have metrics for your income, purchasing history, etc. Someone can buy a list of email addresses of people with income > $x who have purchased a car in the past 6 months, etc.
There is also a way that they obtain data via public records, etc., simply by requesting it from each municipality.