The act of petting an animal and the terminology used to describe the relationship between animal and human companion are homonyms. They sound the same and in this case are even spelled the same, but they have different meanings. In this case in particular, they seem to have a close relation. If you pet your dog he will probably smile and wag his tail, but if you ask your friends if they want you to pet them, would get some weird looks and a bone chilling silence. So don't do that. Your pet, switching back to the noun here, surely loves to be comforted with a good belly rub. It seems to be universally loved by canines, regardless of breed and background.
The Root of the Behavior
To be clear, the universal enjoyment from petting is not solely with canines, but all mammals. Obviously some form of familiarity or comfort with the person stroking their fur is important, but that is not because they do not enjoy the physical sensation. Rather, it could be due to the increased anxiety of someone new in their environment. Again, a pretty universal feeling. The very first time you got a massage you were probably a bit nervous as well. The reason your dog enjoys a good belly rub or back scratch likely mirrors all the same reasons you do. It is calming, reduces stress and anxiety, loosens up the muscles, and provides them a great comfort. Between you and your dog, it is a show of affection and just the quality time they get with you should not go understated here. Many dogs crave being petted to an obnoxious degree due to this alone. Other times they want to be petted out of boredom. Quite simply, they have nothing better to do and so might as well. This is not to say this a bad thing, dogs get bored sometimes, regardless of how well and actively they are treated. If I can break the fourth wall here for a moment, I use 'universally' pretty liberally here. This is because, well, it's true. A vast percentage of canines love to be petted, but there is that infantile percentage that does not. Dogs who do not enjoy being petted do not really fall into one category. Some may not like being touched at all, perhaps due to some trauma in their past, some may not find it a pleasurable sensation, while others just might be the canine equivalent of Mr. Scrooge. Canines have a wide range of personalities and cannot really be painted with such a wide brush.
Encouraging the Behavior
As if to accentuate that point, even though almost all dogs enjoy being petted, they do not all enjoy being petted in the same ways. There are some standards, if only considered standards because most canines seem to fall into this category. The most common places a dog will enjoy being petted are from the belly extending throughout the lower side of their body up to where the neck turns into the jawbone. Shoulders and back are common as well. Ingrained as a sort of natural defensive mechanism, most dogs do not enjoy being petted on the more vulnerable and essential parts of their body. Contrary to popular belief, your dog probably hates being patted on the head. Included in this are going to be other essential and vulnerable areas, such as the feet, tail, and joints connecting them all. Who could blame them though? If someone came up and patted you on the head, how would you feel about it? Maybe this is not why you sought out this information though. A portion of you are likely seeking this information because your dog does love to be petted, and loves it to the point of a relentless burden, forcing themselves under your hands at every given moment. The good news is, they are probably not addicted to being petted. Typically, high attention-seeking behavior like this comes from just a few different sources. Your most likely culprit? Boredom.
Other Solutions and Considerations
If this is the case, then finding some toys they enjoy playing with or increasing their level of daily exercise and activity will quickly help diminish the frequency. High-strung and easily spooked dogs will often exhibit similar behavior, and if you believe this to be your case, then providing them a safe and secluded environment where they feel comfortable should help. They are essentially seeking constant affection because you are the one place they feel comfortable and safe, but this can easily be a dog bed in an out of the way part of your home. They do not need a whole room, but a small area that is their own and as far removed from the hustle and bustle of your home as possible. Dogs who have experienced a trauma or have otherwise aggressive tendencies should be petted with care and only by those who can read their body language. An unwanted pat on a dog who is scared can result in them lashing out. Overcoming these issues is best left to a professional trainer, as we wouldn't want your dog to hurt anyone. These types of things end poorly for both parties.
The key is just to read your dog. If you try and pet them somewhere and they withdraw or jerk back, then they probably didn’t like it. On the other hand, they will embrace it if they did. A dog has never been known to carry a strong poker face, which makes them easy to read. Take note of how your dog reacts, and they will communicate to you in their own way exactly what they thought of it.