Dogs pick up on body language better than words.
Your dog doesn’t see a hug as a way of you showing love. He sees it as you trying to hold him down or restrict his movement.
Dogs also see this as a sign of aggression.
It’s uncomfortable and confusing to them.
Dogs see this as a challenge.
Yelling scares and confuses them.