I had to google this one and I came up with 'mirroring'.
It's part of a few personality disorders and other physical/mental conditions.
I also found an article on Echopraxia which is the involuntary copying of other people's actions- which is also symptoms of other conditions.
https://en.m.wikipedia.org/wiki/Echopraxia
If this behavior is negatively affecting your quality of living, I'd consult a GP or a mental health provider. I wouldn't be alarmed if it isn't life altering...it's just a thing. The article is quite blunt and don't self diagnose yourself. It's just a possibility.
I hope this helps.