Usually, though, it's something they say, or do, that prompts me going there. I used to, as a kid, be able to tell that people were saying one thing (often due to social propriety or personal gain) but actually felt
another. When I then responded to what they were feeling instead of saying, I'd accidentally expose them as a liar or make them uncomfortable. That's something I...was severely punished for. Over the years, I became better at gauging when it was in fact secretly desired that I respond to their feelings instead of their facade. It's often the whole ' I have to behave this way coz that's the rule', when many people are in fact...well, lonely, scared and in dire need of a hug. Or some laughter. Or feeling desired and wanted. Or just comforted.
I usually only do it with people I know well enough to gauge, make sure the situation wouldn't embarrass them (too much) and make sure the gesture wouldn't impede on their sense of self (for instance, it's better to subtly put a hand on the person's hand than hug them if they're fiercely independent and don't like to look weak - ever, unless they're *really* overwhelmed and in need of oxytocin and they *really* trust you).
I also often wrap it in a 'funny' and teasing context, so that they can laugh it off easily if they prefer not to look too vulnerable (and I'll instantly go more serious and nurturing if I feel them responding like a ravenous person). This is also often my way of 'flirting for fun' where the point is to create a little bit of tension and a pinch of uncomfortableness that can be really pleasant for both parties, as it gives you the ability to safely stretch and explore your limits/boundaries at your own pace. Meanwhile, you notice with the first bantering comment you throw their way whether someone is up for that, slightly uncomfortable but secretly loving it, or absolutely turned off by it - you don't even have to touch them yet.
I have, on occasion, done the 'space invasion' thing with complete and utter strangers, but that's usually more because they're falling apart emotionally in my arms - not because I instigated it - and are in dire need of an IV of oxytocin. Some people just don't have anyone to talk to in their lives OR, feel too embarrassed to be that 'weak' around anyone they know. A stranger they'll never meet again is a safer bet