Dogs are loyal because they have evolved from life as pack animals, so they have a strong urge to protect and serve the alpha in the pack, which has become their human owner or family, according to Dr. Zawistowski, an ASPCA science advisor. Some people believe that dogs are only loyal because they need food and shelter from their humans; however, studies have proven otherwise.
Watch a dog after its owner returns from a long trip or a stint overseas, and the love and loyalty are palatable. Dogs can become loyal to humans, other dogs and even other animals because they are genetically wired to focus on the members of their pack. Dogs were not meant to be alone, and when taken away from their pack family of dogs and placed in a human's home, the human becomes the pack leader, and the rest of the humans in the home become members of the pack. The dog then becomes fiercely loyal to the group.
Dogs are also affectionate on their own, and want to bond with whomever they encounter. They do not have a natural desire to attack, and dogs who do have that instinct were bred and trained to have it.