Quick animal trivia fact: domestic cats love it when you hug them. Definitely not dogs though. I've seen some dogs bite people, including a little girl once, for hugging them. Because for them it's a form of dominance and aggression. (I don't know though. We had some dogs we used to hug. And they seemed to know we meant well. But probably only because they were used to us doing it.)
I think most dogs and cats like to be hugged by at least some people. Some don't like that, and many might not like a stranger doing that.
Our dogs like cuddles and hugs, but I'm wary of anthropomorphizing them. While Harry Harlow's work might suggest that there are mammalian contact comfort needs in common, perhaps similar to 3 or 4 year old humans, they are canids, not humans. Superficially similar behaviors might be in response to entirely different stimuli and motivations. While they can express what could be interpreted as affection, perhaps it's simply an obsequious display of subservience because I'm the one who fills their food bowls and water dish...sort of like marital relationships, except that dogs never seem to resent you for it. If you're married, you should definitely get a dog. That way, somebody's always glad to see you when you get home.