Answer: Stimulus generalization.
This is caused by fear or trauma (attacked by a fierce dog) is generalized to encompass similar stimuli (fear of all dogs, whether aggressive or not). Sometimes this effect wears off, but sometimes it will longer for years or even up to a lifetime, building into a phobia.
Hope this helps.