Just as a hug can reassure another human that "everything's going to be ok," gentle touches and trunk strokes can carry the same message between elephants.
Elephants are extremely social creatures that establish strong bonds with each other. They fiercely protect babies and mourn their dead, so it's not too shocking to find that they also console one another, too.