Yes most dogs do enjoy being petted and find it relaxing and comforting to them.
It's also a good stress reliever and relaxing activity for the human to sit there and pet a dog on their lap or sitting next to them.
Most dogs will enjoy you petting them although if it's a strangers dog then you should ask permission first and get to know the dog before trying to pet the dog.
I've petted many dogs while out walking in the park and they've enjoyed being petted but I've always ask the owner permission first and then easily approached the dog.