Most people do this stuff and it stresses dogs out, so they can bite!
Doing this to a dog who doesn't know you is like a perfect stranger giving you a great big hug and kiss in an lift. And wouldn't that creep you out? And wouldn't you have the right to defend yourself?