Most dogs do not care for being grabbed or hugged around the neck. Neck grabbing is a very aggressive action to a dog and lots of them will try to defend themselves. Many may tolerate it, but it's not something they enjoy, especially when it's done suddenly by a stranger.
My last dog didn't like it either, and when little kids would run up to us wanting to hug or pet him, I took the opportunity to educate them on how to approach a strange dog.