Related to Andrei Volkov's answer, I don't think we need to tie supra-mundane phenomena (chakras, etc) into our explanation of why this happens.
However, in a Buddhist sense, this is very relevant and related to how the concept of self is formed. Because what we perceive as the self is not a "true inherent fact" and is, in fact, a dependent and co-arising phenomenon that occurs with many causes, it is dependent moment-to-moment on many different things. Any person who has drank alcohol can speak to how that affects a person. There are many studies about psycho-active drugs or medications of many kind which affect what we consider to be the self. In terms of company being kept, psychology can refer to it as "Mirroring".
When you speak to someone and they have expectations about you, they are not just keeping those expectations in mind- they are in fact crafting the conversation with the idea of you they have in mind. So someone who has not spoken with you in years will continue to expect you to be the same, and will craft their conversation based on this. You might then see that the conversation almost creates a slide for you. If you behave as expected, the conversation goes more smoothly. Due to attachment and aversion, we generally dislike being in awkward social situations, so when we behave in a mindless way, we get on that slide in a drive towards what we like (social cohesion) and away from what we dislike (social awkwardness). If you instead behave differently, it is like stopping yourself on the slide, standing up, and going a different direction. You throw the other person off-balance (at least for a moment, they might quickly recover) and create at least a small amount of social awkwardness. Many many people have a lot of aversion towards even momentary social awkwardness.
This also happens when you keep company with people in general, but it's especially noticeable when you are very different from them, or when they remember a different set of behaviors from the one you have now. People try to make conversations go as smoothly as they can, generally, and they do so based on their own experiences or memories.
One thing the Buddha talked about was keeping good company. In this way, we can use Mirroring to our advantage. If we have friends who are virtuous and expect others to be virtuous, it becomes easier for us to also be virtuous. So, in a mundane sense, if you find yourself behaving in a way you dislike when speaking to certain people, it's reasonable to avoid those people as a result.
If you are unable or unwilling to cut contact with these people, following the Buddhist path will be helpful. As you become less attached to social cohesion and less averse to social awkwardness, it will be easier to face the walk away from the slide. Cultivating mindfulness will also help you notice when you are being affected by others in this manner, allowing you to manually step in and stop it.