Sometimes when I go over to most his cage he fires up and flattens himself out like a pancake, all while balancing on his back legs. I assume this is some kind of defense mechanism?
He's trying to look like a leaf and, failing that, too big to eat.
It's a common and relatively mild response to interaction with a potential predator. If it's constant, frequent and accompanied by any other stress indicators, it might be something to address (first with terrarium placement and internal arrangement) but if that's the extent of it then you're just an occasional witness to an instinctive defense mechanism.
Thank you. I just got him last night and he had a long car ride home so I imagine he's just a bit stressed right now. It's only when I point the mister at him or come near him wearing long red sleeves. Otherwise I can walk up and with persuasion get him to crawl onto my arm (usually offering a superworm on my arm). I get the occasional hiss, but this pancake trick was a bit nerve wrecking since I hadn't read anything about it yet, and the fact that he could make himself so flat made me think there was possibly something wrong. He makes himself so flat that his ribs curl inward and make him look like he could hold water on his side as if he were a bowl.
There are some very subtle differences involved between the two, but it's commonly something seen when encountering potential predators and potential rivals. Laterally flattening like that makes them look bigger in profile, flat surfaces are slightly more difficult to bite and the shape is less common, so some predators will be a little more inclined to not see them (or not recognize them as edible).
The color association, if it proves accurate, is an interesting tid-bit; for reptiles, they have relatively complex body language and it includes some degree of visual communication based on color as well as posture and action.
If he's that recently acquired, it is really not surprising. It is a good sign that he should probably be left to settle in before approaching him too much. As a group, they're a bit on the sensitive side when it comes to changes, stressors and stimulus. Veiled are hardy and laid back for chameleons but ultimately that's still a limited definition.