The Root of the Behavior
It is essential for this type of breed to get enough daily exercise. Being cooped up gives them far too much pent up energy and it gives them no way to release any stress or anxiety. They can also be extremely overprotective, and it is important to remove them from any environment where they might perceive you or those close to them to be in danger. For instance, if you have children and they like to rough house with their friends, your canine might not perceive that as the fun and friendly game it is supposed to be and consider your child to be in danger. If they perceive that danger, they can be extremely overprotective and attack the other child. This is a disastrous situation. To make sure your canine is not going to attack anyone in the future, there are measures you can take and training you can do. Canines who are intended to be guard dogs need attack dog training to make sure they do not just attack for no reason.
Encouraging the Behavior
This can also stem from past trauma or abuse the dog has received. Your best course of action is to train them from a young age. The earlier you get started, the more success you are going to have. Socialize them at an early age. This means you should bring other canines around when they are young, have other people at the house, and make sure they do not feel like they are the only canines and you are the only person allowed in their territory. Even a young German Shepherd may react poorly to visitors, but at this age they will not have the power to do any real harm and they will get used to having company.