By nature dogs are territorial animals and yet most dogs are quite tolerant when it comes to both people and other animals. As with anything else dogs are individuals and you will find that your dog may be over friendly with every person and animal it comes across, while another may show hostility to everyone and every thing that it meets.
Many animal lovers will have more than one dog and may even have several different breed of dog as well as other animals. Under such circumstances keeping everything under control can be a real challenge - if your neighbor's pets or any other wandering animals enter the territory then guarding your home and your sanity gets even harder.
One way of reducing the strain on your home and patience is to socialize your dog at the earliest possible opportunity. Puppies, like children are much more accepting of strangers as it takes time for them to distinguish between friend and foe.
Life is simpler with just one dog, providing you start exposing it to people and other dogs as early as you can. It is a good idea for your puppy to become accustomed to being touched especially in sensitive areas such as between their toes, in the ears and near the eyes. This will not only impact on how they interact with other animals it can make trips to the vet a far less stressful process. Dogs will sniff everything and this can be a problem when they are about to interact with each other. Until you are confident that there won't be any fighting or chasing keep them under control while they explore the other animal and are explored in turn.
You should keep an eye on your dog if it has a tendency to leap or bite and intervene quickly if it looks as though someone might come to harm. It is normal for dogs to indulge in the sort of rough play where they knock over one another and sometimes nip legs and necks. Stay close to the action so that you can pull them away if necessary, you may need to protect your hands with leather gloves in the early stages.
If your dog barks continually try to distract its attention with a toy, treat or sharp command. You may need to come back another day if they refuse to stop barking or pulling. What works for one dog may not work for another and there will always be those who cannot tolerate others. Observe their interactions over time to discover what works best with your dog.
Sometimes it is worth putting your dog on its back and hold it still by placing a firm hand on the chest. In some cases it may be necessary to shout or bark in your dog's face. While bystanders may consider you a lunatic you can take comfort in the fact that some monks in upper New York State apply this method and they are renowned for their success in training German Shepherds.
If you have a rescue or animal shelter dog then you will need more patience when you are socializing the dog. Unfortunately these animals may have been abused by a previous owner or injured by another dog which can result in fear and aggression. Nonetheless it is possible to change this with consistent and patient training so that with repeated exposure to other people and animals they become more tolerant. If you begin the socialization process early on and expose your dog to others for short intervals, gradually extending and repeating this you should be able to socialize your dog.
No matter how hard you try there are animals who will require specialized training in order to teach them to get along with others.