According to the dog whisperer, they can tell by your body language whether you feel confident or not. So they will either try to dominate or feel uneasy by your body language and be violent. If you’re relaxed than it tells them there is nothing to fear. They may not know its them that you are afraid of but your tension makes them feel anxious and tense.
Some dogs are just very comfortable with people and will try to show you all is well. My dog always tries to cautiously approach fearful people. He will take his time getting near them till he feels they are in a more relaxed state. At least its what I’ve noticed with his behavior. If they are extremely fearful he will then bark at them.