@art-venture thank you so much for your comment :) there are a number of factors to consider when interacting with doggies, from their upbringing , living conditions etc. but a fundamental understanding is also how we interact with the animals, their senses are considerably different to ours and they have been know to be able to sense our emotion as well.
Examples of this include, that when owners are sad (emotionally only, no expression of it ) the animals can try comfort them, when a owner is angry the animal responds in an agitated manner etc. it is possible that your sense of fear gave your doggie the sense that it should be scared and it lashed out as a result to try neutralize its negative emotion. Its funny how little credit we can give to animals in sense of intelligence but they have these abilities which may be considered to be "superpowers" :)