The human mind has the capacity to deliberately forget, allowing the amnesia state to wash away bridges between chemical memory lanes. This is but a step away from compartmentalizing memories into packages the human feels capable of dealing with at one time.
Brain chemistry and brain structure wise, the process is the same. The average human can point to instances in himself or others where selective forgetting occurred. One just forgets that embarrassing moment or that appointment to go to the dentist. In amnesia the chemistry in the brain shuts down to the extent that the conscious brain is not recording new memories or playing back old memories. It's off-line, rather than on-line, as they say in the computer business. Individuals recovering from coma move in and out of this state when first awakening. Selective amnesia attacks just those bridges that lead to painful memories, washing these away. Here the conscious brain chemistry is not affected as a whole but is altered at the site due to the strong emotions engendered. The chemical process, however, is the same for selective amnesia, total amnesia, or multiple personality disorders.
It's not uncommon for humans to have what they call different sides, or to have what is called a Dr. Jekyll and Mr. Hyde personality. This is the same mental technique that those suffering from multiple personality disorder employ. Situations and the responses to those situations that are by their nature incompatible are compartmentalized. Take anger, for instance, a common facet of the personality to be suppressed. The little boy who is punished for expressing anger represses this, but the boiling rage he feels at times expresses itself when he is out with the other boys, in pranks. He may package other aspects of his personality into this persona too, so that he is not only reserving anger for these times, but being messy and slouching rather than standing straight, too. Rebellion time, a common situation in adolescence.
Individuals who develop multiple personality disorders are raised in harsh and hostile social environments where conflicts and duality are rampant. Children who observe hypocrisy in the adults around them soon pick up this duality, but most often it is a conscious duality. One compliments someone to their face, but behind that individual's back denigrates them, being two-faced as you say. In multiple personality disorder the need to be two-faced is extreme, and is not just a nicety but a lifesaving tactic. If mother cannot abide discussing sex much less observing any expression of sexual heat, but father is molesting the children regularly barely outside of the mother's view, then extreme duality is present. Perhaps things get broken at those times, in the tussle, but where mother ordinarily demands immaculate neatness she has a remarkable tolerance for broken lamps and tossed pillows after a molestation episode - more duality. The child trying to cope in this situation may thus package their messy persona in with their sexual persona.
In response to the duality their childhood presents, the human developing a multiple personality will compartmentalize the various aspects of their personality. Anger, the sex drive, curiosity, aggression, greed, sloth, artistic expression, fear, compassion - those aspects of the persona that are compatible are packaged together, as they are let out to be free at the same time. For multiple personality disorder to develop, harsh duality is not only present in early life but is the situation throughout childhood and frequently into early adulthood. The compartmentalization encompasses their whole early life, and forms the base for the later years. Thus cut into pieces, the sufferer finds they cannot cope with ordinary life. The socially proper persona may be on-line while the individual is standing in the checkout line when someone nearby drops a jar, shattering the jar and splashing tomato sauce everywhere. The proper persona goes off-line, in distress, and when the messy persona takes over those at the grocery store find themselves standing next to an entirely different person!
Invariably, in multiple personality disorders, the individual is not able to cope. This permeates their life, evident in social situations and employment alike. Ordinary living requires the many sides of an individual to be present at the same time. A business meeting requires one to be calm and orderly to absorb the subject matter, but also to be aggressive when presenting one's opinion, fearful of being rejected, and angry when rejection occurs. An individual who has rigidly packaged their persona may find at least three different persona called out during such a meeting, ineffectively handling this social situation and startling their co-workers. Thus, they get fired, become reclusive, and often remain in the home where their personalities were warped in the first place - the victim yet again.