The Root of the Behavior
Overprotection in many forms simply comes from jealousy. A dog who receives too much attention during their younger years or one who has to compete with another dog for the human companions attention will often develop overprotective or aggressive behaviors. Your dog likely falls into this category if the aggression comes when you are petting another dog or hanging out with someone else. Canines who form a special bond with a singular member of the family may try and protect that member from other members of the family. Even though that individual is never in harm's way, any actions that may seem like they are impacting their safety. For example, wrestling or goofing around with someone or another pet can cause your dog to launch out at the perceived attacker. This is the more traditional form of overprotective behavior and does not apply only to members of the family. Any friends or even strangers they believe put you at risk and they will come to your aide.
Dogs who have received formal training can usually shed this behavior and owners who understand what is going on can usually quickly and easily correct it. Dogs who display any real forms of aggression should be treated for it as soon as possible. Contacting a trainer to correct the aggressive behavior is not just essential to protect the people around your dog but also your financial well being and your dog's life. If your dog perceives you to be in danger and hurts another person, you could be sued for a fortune and in most states, your dog would be put down. Putting your dog down would not be an option but many states require just that from any dog causing injury to another. This may also help protect other dogs you have in the house. An overprotective or jealous dog could cause injury to another dog in your house simply because they are getting your attention instead.
Encouraging the Behavior
If you are anything like my sister was when we were growing up, she would take advantage of this. We had a Chihuahua that favored her over everyone else. Whenever she wanted to mess with us she would feign fear and the Chihuahua would launch itself at us. This can be hilarious, however, it is not a healthy behavior and if it was a bigger dog it could have put us at serious risk for injury.
Unfortunately, in this case, it provided reinforcement to the dog's actions and they believed that this level of protection is what she needed and wanted. Once this cycle of reinforcement begins, it becomes exponentially harder to correct the behavior. If one day your dog feels rewarded for being overprotective and you try and correct the behavior in the future, the dog will simply not understand why you are upset and your efforts to correct the behavior may just be in vain.
This is why it is important to instill the best practices around your home and with your family from the time the dog is first introduced into the home. This is the best way to ensure they do not develop into over-protective or aggressive dogs.
Other Solutions and Considerations
If you are past that point and are already dealing with an aggressive dog then addressing this behavior quickly and every time is essential. Cutting corners in this process put you and your family at risk and if you cannot correct this behavior on your own then you need to contact a behavioral specialist or trainer so you can stop any aggressive behaviors. This is essential for you and your dog's safety. None of this even considers the fact that an overprotective dog may pick a fight it cannot win. If they believe they are protecting you and you need the protection, they may fight a dog they are hopelessly outmatched with and end up with serious injuries themselves.