There's a fairly long answer given in the YouTube explanation by "SuperCarlinBrothers".
Basically, Buzz Freezes for the same reason you and I can't stick our hands into a fire.
I'll transcribe some of the main points here, but I think it's best for you to go and take a look at the video.
3:45 onwards features some of the main points:
"Buzz isn't alone in this camp. There are other toys whose personalities are confined to the type of toy that they are. (...) The green army men know they are toys, but still act like green army men."
Green Army Man: "A good soldier never leaves a man behind!"
"In contrast, toys like Ham, Rex, Slink and Mr Potato head don't act like pigs, dinosaurs, dogs or talking potatoes... they know waht they represent; but their creation as a toy was for the sole intent of being a toy- simply, objects meant to be played with (...)
"Finally, that leads us to Buzz. Buzz is a step in the complete opposite direction. Buzz is the victim of whast we are going to refer to as "placebo branding (...) his mentality is being influenced by extensive branding that comes from being based on a real character."
Woody: "You actually think you're the Buzz Lightyear?!"
"so why does Buzz freeze? Because, no matter how hard you believe it, it doesn't stop the true from being true. (...) you can believe that sticking your hand into a fire isn't going to hurt you, but good luck with that. Buzz can believe he's a space ranger all he wants. But he's still inside this box. The toy box."
All credit goes to the vid, left to myself, I would've said one of the dumb theories mentioned at the beginning of the video (flight or fight etc.)