I'm sorry if I'm reopening something that's been forgotten but I've been doing some research on a project of mine and this topic is a direct result of my research.
From reading all of the responses, I'm partial to the programming idea from the basis that this Buzz and all his creations are at least, in partial, computer based. However, I have read an article that gives an interesting perspective on the story as a whole, not about the child and his development, but how the toys are, in a way, a parent to a child even though they are solely dependent on his playtime.
Did Disney Ruin Pixar
While the article isn't about the paradox of the toys being like parent to Andy; the mention does detail a good flip notion of how the toys are so important and why they act the way they do.
This leads into my point that maybe this isn't about programming but more about psychological development of the mind, like the mind of a child. Given that these toys don't have brains, but their thinking processes are similar enough to human development that it would lead one to think that perhaps coming out of the box is similar to a child going to his first day of school.
Taking Buzz as an only child, his whole existence up until now is of being Buzz Lightyear, "THE Buzz". The reinforcement of who he is from the TV show, the advertising on the box and Andy's belief when playing with him are conditioning behaviors that help Buzz maintain his identity. It changes when he enters a room full of other toys, that give him the opportunity to expand his mind, though like a stubborn child he will naively hold onto his belief as long as possible until he has a tantrum.
While the plot maintains that this is something of a menace to the group (especially Woody who has to at least keep the toy Buzz within Andy's reach, as is shown in his attempts to get him back in the car at the Pizza place despite his angst feelings about the new favorite) there is nothing (to my memory) that gives the audience evidence that this is a phenomenon or a unique experience. It could happen with every toy they encounter out of the box.
Another case would be of Mrs. Potatohead; she was a new toy that came out of the box during Christmas time at the end of the first movie so we don't know about her situation and acclimatization to the group between movies 1 & 2. In fact, it could be that she never came out of her phase as she was doing/acting as a loving caring wife in the second movie, helping her husband pack his bags before going on a trip. So with the reinforcement of having a husband, Mr. Potatohead, she is able to continue her role without much converting.
Theoretically, the more reinforcement there is the harder it is to break the spell into understanding that they are toys to be played with; hence the toys in the store maintain their composure or predefined roles. The barbie tour guide is only a tour guide (she could be a guide of a museum of which it seems she is displaying, or any other location that employed guides). Therefore the toys that have yet to be bought will maintain their identity for as long as they are at the store.