If seals are more closely related to elephants, why do they behave more like dogs? Indeed, they should be called seadogs. :hmm:
Current knowledge indicates that the pinnipeds (seals, sea-lions, walruses, etc) are more closely related to the bear family and the otter/weasel family. It could have had a common ancestor that lead to canines, or evolved concurrently with canines.
I haven't studied that in-depth, just glossed the surface. You encouraged me to look because I could have sworn elephants were not at all related to seals, in any way whatsoever.
Dolphins and the other cetaceans, also incredibly intelligent and social animals, appear to have a different evolutionary path. The closest living relative might be the hippopotamus, by way of sharing a common ancestor with the early even-toed ungulates.
Going back to those points in time, they were all sort of sharing common ancestors. Canids are just as much of a distinction as pinnipeds... whereas the cetaceans (dolphins, whales, etc) appear to have diverged even earlier from mammals, perhaps from common ancestors that also split later to become other carnivores (as well as herbivores, considering the ungulate lineage).
There are a lot of theories about which came first and which is an ancestor to which. It's tough to have a firm answer, obviously.