Breeding is a large part of temperament. Dogs have been domesticated so long now (Google gives different answers, does anyone know?). But over thousands of years, we have bred in and out different qualities for different breeds, depending on what "job" they have.
So guarding, herding, ratting, racing, hunting... all of them, to companion dogs, deliberately have different qualities (our responsibility). But they are also all individuals and learn, feel fear etc.
If you put the wrong type of dog in an environment it can't cope with, without the right care, you are asking for trouble. And that's even without taking into account deliberate abuse.