The relationship between dogs and bicycles can be described as complicated: who hasn't had to speed up when faced with a dog that wouldn't stop barking at them.
As Pablo says, the first thing you have to do to understand them is to think like them, and in doing so, there are three options for why a dog attacks: Aggressiveness because of fear.
The dog attacks out of fear of you, if you move away it should calm down.
Dominant, defensive or protective aggression.
Attacks because there is something it wants to protect (home, offspring, etc).
Predatory aggression (used for hunting).
In the previous two cases the dog should not chase us, but in this case it could.
This type of attack is usually related to the animal's hunting instinct, in which case if we stop the dog should also stop, or to the protective instinct.
Dominance aggression is the worst, as it means that we have invaded the dog's space: in his house, near his flock, his pups, etc.