An experiment at the University of Veterinary Medicine in Vienna, Austria, suggests that dogs behave altruistically toward other dogs, especially toward dogs they know.
The experiment involved teaching dogs to pull a string that delivered either a treat or an empty tray to another dog in an adjacent cage. Dogs showed a preference for delivering the food tray, especially when the other dog was known to them. This involved multiple trials to attempt to rule out random accidents and other explanations.
More details at this link.
Such “prosocial behavior” has been seen in a number of species, sometimes instinctual (as in the case of vampire bats who feed starving colleagues) and sometimes involving situations not normally encountered (as in the experiment here) and hence likely reflecting some level of thought. In other research I’ve read about, primates have also shown prosocial behavior, and in addition primates and dogs have exhibited annoyance when seeing another animal receiving apparently better treatment. See this earlier post, which has an amusing clip of the experiment in action.