Dogs chase cars because their predatory ancestors hunted by running down prey to exhaustion. To this day, swiftly moving objects stir a dog's instinct to run down the "prey" even if the "prey" is an inanimate object, such as a car or a tennis ball.
Not only do all dogs posses a certain instinct to chase, but certain breeds in particular have had their chase instinct modified in such a way that they are more likely to run after cars. For example, working breeds like retrievers have had their hunting instincts diverted into fetching game for human hunters. Shepherds, bred for generations to herd cattle, are particularly prone to car-chasing as the large, swiftly moving cars generically resemble the creatures they were bred to chase.