You have a single brain but you are not a single personality. Multiple versions of you display themselves to the world depending on the environment your brain finds itself in. There are parts of you that only personal “environments” like close friends or family get to witness. You may have a professional persona that is almost always confined within your work place.
At the level of genes, a similar phenomenon is observed and is known among Biologists as Epigenetics. A single gene or a network of many, shows its effects (or not) depending on where it finds itself in the body. Every single gene is in each one of your cells but decides to stay silent in most of them. The genes responsible for making your kidney cells are present in your heart cells too. They are just locked in a permanent state of sleep. This is what Evolution thought as the most efficient way to maximize diversity with limited resources. As far as Natural Selection is concerned, it’s laws of economics all the way down.
Our personalities are nothing but varying neural networks that are formed inside our brain over numerous years. These neural networks are in effect exactly like a network of genes but operating at a phenotypical level. The environment in this case, unlike the location within a body (as is the case with the network of genes), is external stimulus that our brain consumes as input. Friends, family, colleagues at work or even solitude are just different environments that constantly decide what neural networks get activated and which ones go silent. So we notice here another recurring pattern in Life that manifests itself at different levels. When you are dealing with a network of “alive” components (neural networks or gene networks), it seems to gravitate towards a form that allows it to take different shapes depending on the physical space it happens to occupy. And all this flexibility in the nature of networks can occur without really changing the fundamental building blocks that make the network itself. Today, we are seeing computer programming evolving into another manifestation of this pattern with the advent of machine learning and deep neural networks. There is even a hypothesis proposing the whole Universe to be a discrete event network (whatever that means).
Networks increase complexity and can take forever to build but there is an air of inevitability about them that may point to something fundamental about the nature of this Universe.