It it turns out all mammals like to be petted or caressed, not just dogs. A 2013 study at Cal Tech found petting triggers special neurons in the brain of mammals called MRGPRB4+. These neurons produce both a calming and pleasure response in the brain. These neurons only respond to stroking or petting and not to other forms of contact.
The researchers who discovered this effect theorize that mammals evolved with the MRGPRB4+ neurons to encourage good hygiene thru social grooming. Note that humans also have these neurons.
A related fact – in a recent study, dogs were found to prefer petting to verbal praise. So – when training your dog, petting should be more effective than verbal praise