In 1999, psychologists Tanya Chartrand and John Bargh ran participants through a task alongside a confederate who was secretly instructed to rub their face or shake their foot at set points. Without being told to, and without noticing they were doing it, participants started doing the same thing — rubbing their own face, shaking their own foot, mirroring whoever they were paired with.
Chartrand and Bargh called it the chameleon effect: an automatic, unconscious tendency to mimic the postures, gestures, and mannerisms of people around you. It isn't a conscious social strategy. It happens below awareness, and the study found something stranger still — the people being mimicked reported liking their partner more and rating the interaction as smoother, without being able to say why.
It functions as a kind of social glue — a signal, read unconsciously, that says "we're in sync," which in turn makes the interaction feel warmer than it would otherwise. You've almost certainly done it today, with someone you've never met before.