Dogs are known to be very territorial. If you have a dog, you will know that they frequently mark their space and guard this territory carefully. Although most dogs will act friendly when they are not guarding their territory, once another canine has come into a space they consider their own, they may defend their territory fiercely.
A dogs territory is probably be the same legal boundaries that are registered at the local courthouse. Sometimes they may even consider your neighbors territory their responsibility to watch over, possibly even from those who actually live there. In fact, if they mark a certain area during their daily walk, you can expect that they will now consider the marked territory theirs to guard. In fact, if you take your dog to a dog park and they mark that area, they may consider the dog park to be their territory as well. The territory your dog decides to guard may also be quite small, such as their kennel or crate, or the car you drive or just the house and yard where you live.
There are some breeds that tend to be much more territorial than others, although any breed is capable of this behavior. This is actually a necessary behavior for dogs living in the wild, but for dogs that are living near humans, the behavior is very undesirable.
To help prevent or fix this issue you should make it clear to your dog that the territory is not theirs to guard. You need to assert yourself as the leader of their pack and make it clear that the territory in question belongs to you. Leader of the Pack, a book written by Steve Duno and Nancy Baer, is a great resource for those who want to learn more about how to portray yourself as a pack leader to your dog. Although this does not always work, it will often help with the problem.
Keep in mind that it is impossible to explain to your dog using speech why they need to be nice to other dogs in your yard. One of the best ways to avoid conflicts from happening is simply to prevent the situation in the first place. If two dogs are going to meet, be sure that the encounter happens outside each of their own marked territory. Only once it is established that they are playing well with each other should you attempt to bring them both into one of the dog's marked territory. If your yard is not fenced, do not leave your dog alone in it unsupervised. Make sure your dog does not attempt to claim your neighborhood as its territory and prevent it from running freely off your property.
Your dog should not be allowed to bark at other dogs from a fenced yard either. This will create bad habits that might be a challenge to break without . Also make sure your dog is not tied or otherwise constrained in an area where there are other dogs. This can be very stressful for a dog. Your dog may become very aggressive in order to try to scare the other dog away.
Dogs need space, just like you and me. Follow the wrong path of defining your dogs territory and you will have to work hard to change that incorrect behavior. For this reason, you need to be sure you start out right in terms of defining proper territorial boundaries for your dog.