Do you think your dog is scared of you? Do they recoil whenever you go for a good squeeze? Maybe they still like a good scratch, or maybe it is only your kids they run from. Whatever the cause, they don't like to be hugged. It's more common then you might think, nearly all dogs have this kind of reaction to a hug and for a lot of different reasons. Biologically they are vulnerable, mentally they are stressed out and anxious and they are often physically in pain, especially from the hugs of children. There are a lot of ways to show affection to your dog, but a hug to them does not typically feel like affection.
The Root of the Behavior
Consider the times when you have had to take your dog to the vet. Once they know where they are going, it can be impossible to force them along. The memories of shots and other unhappy visits come flooding back and they resist as much as they can. Then you pick them up to put them on the table directly before the unhappiness commences. This is probably the one of the only times in recent recollection you've picked up your dog. The dog however likely remembers your kids grabbing and squeezing far too tight. These are overwhelming and restricting things. The act of squeezing immobilizes them, restricts their lungs and airflow, and constricts their muscles uncomfortably.
The body language they exhibit should show you just that. Their muscles get tight and they pull away. If they are wagging their tail and having a good time, then by all means hug away, but if they pull back or growl, you should let them go. They are uncomfortable with the situation and are trying to tell you that. If your dog has violent tendencies or aggressive behavior, do not let others hug your dog. A low growl or bark and an aggressive stance indicates violence may be coming. Remove your dog from stressful situations and de escalate the situation. Do not use treats to calm them down afterward, as to them it feels like they are being rewarded for defending you, and will likely continue the behavior. Most dogs will not lash out if they are being hugged, but most will in some way try and show that they are uncomfortable. Your dogs communicate through body language and it will be easy to tell if you pay attention. They readily present their intentions and feelings in almost all situations. Read it and react accordingly.
Encouraging the Behavior
If the human companion has mental deficiencies, physical handicaps or needs a comfort animal that can be trained. Proper training should be taken with any comfort animals, it really should be done by a professional. Training a comfort animal or support animal. Over time an understanding will come naturally and your dog will react better to being hugged as they will know you need it. It is not comfortable, this is an unnatural position for them. Some dogs do not even like being pet, though that behavior is done so often it becomes natural to them quickly. They understand it is affection at that point. Dogs needed for assistance are specifically trained for the care of their human companion. In most other cases you are removing their ability to flee, their primarily self defense. Repeating light hugs over time will naturally familiarize them with hugging, but that does not really mean they enjoy it. They may simply just tolerate it from you. An easy behavioral cue to look for is the breaking of eye contact. If when you hug them, they turn away from you, this is a sure sign they are uncomfortable with the situation. Some dogs may enjoy a good hug, and if so, by all means give it to them.
Other Solutions and Considerations
A behavioral specialist should be your first call if you need training for a canine intended for therapy or assistance. Avoid allowing others to hug your dog if your canine exhibits aggressive behaviors or tendencies. Damage your dog causes to others could cost you heavily financially and lead to the end of your dogs life. Work with a trainer to insure your dog is safe for others to interact with. In most other cases a hug will not cause a violent outbreak, just an impulsive rejection of the behavior. They will turn tail and try and escape your embrace, and if this is the case, you really should just not hug them. Pet them instead.