Remember that humans domesticated dogs by selectively breeding the dogs that had desirable or human-like behavior. The selection for human-like behavior was sometimes unintentional, such as when our ancestors selected dogs with human-like yawns: dogs and humans are the only species that can catch yawns from the other species. (Caveat: recent research might have found other species pairs, but it is still rare and, more importantly, humans do not catch yawns from other primates.)
Therefore, it is plausible that our ancestors selected dogs that had moral behavior that was more similar to the instinctive moral behavior of our ancestors.