One of the most common questions I get when holding an animal communication session is "why does he/she bark (lunge, nip, insert your companion's behavior) when people come over?" The answer in short is "because they are dogs", but there is much more to it than that.
The first thing to consider is your dog's personality and breed. There are breed-specific behaviors like cattle dogs instinctively trying to herd you together. That said, some dogs defy their breeds' behavior. If human, we would call them "rebels". I like to think of these dogs as very intelligent, strong-willed, confident, and creative. Their personalities go beyond what is genetically instilled in them. I am a bit of a rebel myself, so I tend to admire those traits. The other thing to consider is your behavior. How do you act when the doorbell rings or when you approach people outside? Do you take a noticeable inhale and say "who's that?" in an excitable tone? If so, you are encouraging them to be on alert. Also, keep in mind that your animals are much better at reading your thoughts than you are at theirs. Humans can have several thoughts going on at once and are often not in sync with each other. You may sound confident in words and tone, but your inner thoughts hold fear and uncertainty. Your companions pick up on this and react.
As with human children, there is the question of nurture versus nature. I do not think that it is either or, I always believed we are a combination of both. I think that when everything aligns (nature and nurture point at the same thing) that is where we get the individuals who excel. For example, a horse who is of racing lineage and loves to run, AND has a trainer who believes in them and trains with love will be a champion racehorse. If that same horse did not like to run, he may be trained well and win some races, but would never be a champion racehorse. He may do well, but not as well as the first example.
I bring up nurture versus nature because humans tend to forget that the animals we choose as companions are not like us. What we think is bad behavior or embarrassing or annoying is only so for us. We are asking animals (dogs, cats, horses, etc) to live in a human world filled with human rules. Some companions acclimate easily; others, the James Deans of the group, do not. (For my younger readers, James Dean was an actor who starred in the film "Rebel without a Cause" om 1955. It was/is an excellent film about teenagers struggling emotionally in suburban middle-class families.)
I am not suggesting that you don't train your companions to behave in what is acceptable to you. I am suggesting, however, that if you understand your companion as a breed and also as an individual, you will get to the sweet spot of behavior quicker. I am also suggesting taking a look at your own behavior as our companions pick up on our silent cues. As with any relationship, compromising goes a long way. When safe to do so, give them the win.
In 'Finding Joy: A Dog's Tale", Little Bear discusses several events where he wishes he behaved better. His self-awareness is commendable. Little Bear also gives us words to ponder in regard to our expectations. He says, "In fact, if I were in the wild, these things would be considered normal. They would be considered great skills for protection, for getting food, and for survival. I was a dog, not a human. Dogs do not have so many rules as humans invented for us. it is simpler for us. Still, I should have behaved a little better, if only to not upset Mommy." (Amato, 139)
Little Bear was aware of my expectations as well as his primal instincts. His acknowledgment of both shows us that animals are more aware of Life than we are. We tend to be aware of our own needs without consideration for the big picture. Evidence of this can be seen in our destruction of the planet. Our need to be in control is destroying relationships and our environment. So how do we live together in our human world with the chosen animals we have domesticated? Let go of the need to be in control of everything. Take time to observe their behavior before you start training. Get your thoughts in line with your words. Be reasonable. Act with kindness and love always.