Dogs, like many predators, instinctually run after things that are moving away from them. This instinct is developed in them through evolution because in the past a dog’s food was anything that ran away from it. It is partly about hunting and partly about defending their territory. All dogs possess to some extent an instinct to chase large rapidly moving objects. Some breeds of dogs are more likely than others to chase after cars because their chase instincts are so modified over time. For example, working breeds like retrievers have 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.
It is advisable to not run when a dog barks at you. It would bark for some time and then lose interest and walk away.