Mostly, if not entirely, due to poor raising.
I've gotten "BEWARE OF DOG!" pitbulls and rottweilers to befriend me simply by speaking kindly to them, and then over a period of days raising that to handsniffs, then petting.
Misanthropic dogs are taught that behavior, which contradicts 10,000+ years of training. They don't enjoy being assholes.
This is not to say dogs aren't naturally barky and suspicious of strangers; that is also part of their millenia of training. Lots of nice people are also suspicious of strangers. But aggressively attacking people is basically psychotic behavior for a social animal that considers humans part of its society.