All polls pre-suppose voter demographics. In other words, they say, I think 43% of voters will be D, 35% R. So when they make their calls, they only take data from that same split.
LongRoom says: wait right there. You used that split in county X where there are 24% D, 65% R. I'll only take your data that fits the correct percentages. They make this adjustment in every state/county/precinct. So some will slide more D, some more R, but it becomes an accurate sampling based on location of the voter.
My guess is, this makes it less accurate for an individual poll because they'll have to weed out certain votes they choose not to count to make the percentages correct. However, by averaging everyone's polls in the same manner, they greatly increase their sample size and make the final average very accurate.