(Of Course it Doesn't)
Some people don't like gender bending fanfics, but I honestly like a well written one. Finding a well written one isn't easy though as many a writer prescribes to the thought that a characters personality would drastically change if they were of the opposite sex. This in part comes from the fact some of the younger writers divide certain personality traits into belonging to a male or female rather then both. Others take it so far as to treat any personality trait they expect in one sex as a bad trait in the opposite sex.
Environment does in fact play a role in who a character does end up to be. Since society expects different things of a male or female child, the way people treat the character will of course change based on what sex the character is. It goes without saying that a characters personality will slightly vary if they were male or female. However, a change in sex does not equate a complete change in the characters personality as there are other factors that make up who the character is.
As I've already said, environment plays an important role in shaping who a character is. Most of the time a character's gender changes, their home environment isn't going to change. If they have an abusive father who will abuse a child whether they are male or female then that child is going to have the same abuse shape who they end up being. If the child grew up not interacting with other children, that will also effect who they are.
On top of this genetics play a factor in what a persons personality is going to be like. On one side genetics cause males and females to have different kinds of hormones. However, this is only a minor factor that changes the characters personality slightly. There are other genetic factors that will stay the same whether they are male and female. For example, each person is born with a specific personality. Some are really stubborn while others are not. This isn't divided into male and females.
My main point is, while a gender bended character will have some changes to their personality these changes are not as great as some of the gender bend writers make them out to be. They divide the roles characters are in to cleanly into male and female roles and thus rely on stereotypes to move their stories along.