The Root of the Behavior
Unfortunately, when hunger and shelter enter the equation, the dog in the wild was ruled far more by instinct and raw canine need than by compassion. Finding shelter to camouflage the wild dog's sleeping area and that of the other members of the pack was a critical part of his survival strategy. Mother dogs would often need to leave the den to procure food for their young. A den that allowed her puppies to be hidden from view and that provided scents that would mask the presence of animals would afford her the freedom to hunt to source food for the pack. Without these things in place, her young could become a predator's next meal. But unexpected things could happen while a mother dog was on the prowl for a food source. If she were to come home to find a hungry animal snooping around her territory, she would need to be prepared to defend herself and her babies. This protection instinct is hardwired into our dogs. Though many dogs do not live in multi-dog homes or have puppies to defend, they still very much identify as being part of a "pack." You, as the person who controls all of the resources, are the leader of this hierarchy. Dogs understand that there is an authority structure in every family, and they have a powerful need to fully comprehend their role in it.
Encouraging the Behavior
We don't like what we perceive as nuisance barking, and we are perplexed when the normally jovial Fido turns into Cujo because the neighbor's Yorkie happens to run up on our front porch, or the mailman drops off a package. It is but one more occasion when canine logic and human common sense don't see eye to eye. What is interesting to note is that dogs all have different approaches to defending their territory and their people. This may or may not be affected by personality. The one thing that is always consistent is that when in the presence of a threat, whether real or perceived, your dog WILL respond. Dogs with gentler personalities may opt to play the role of "peacemaker." Instead of showing more overly aggressive behavior, these dogs often choose instead to lower their body posture, avoid eye contact, and freeze in position. This is an attempt to communicate that the dog does not want to engage with the aggressor and is sending the signal that he means no harm and will not fight if the opponent is willing to drop his "offence" and walk away. Some dogs respond to worrying situations by heading for the hills. After all, you can't get into a fight if you aren't around to fight with!
Other Solutions and Considerations
However, dogs do still bear the imprint of their roots as wild dogs, and ancient behaviors sometimes rise to the surface in the face of frightening situations. Witnessing their dogs in protection mode can be very scary for owners. For dogs more prone to extreme territorial behavior or prey drive, it is critical that the dog is securely contained for his own safety and the safety of others. But more than this, a dog that exhibits extreme reactions to threats needs intervention from a reputable professional dog trainer. Dogs who frequently exhibit aggressive responses to low-level stimuli are dogs who are struggling, and they need help. Dogs defending themselves and their families is very normal behavior for them. As their owners, it is wise for us to limit the situations our dogs find themselves in where they feel the need to respond in a reactive fashion. Sometimes, it is not possible to avoid these things. Life is messy, and things happen. But if you are aware of something that always triggers a negative response in your dog, it is best to simply remove it from your dog's repertoire of things or places to visit. Your dog will be much happier for it!