It shouldn't have surprised Sam to suddenly be faced with his brother, though it did. Snape had figured out, much like all the other enemies Sam had faced, that Dean was his weak spot. It wasn't much of a weak spot, because his brother was also his greatest strength, but it was a weak point nonetheless.
He took a step back, but raised the gun again. "You're not Dean," he said firmly. "You're not real." He could feel the tangible power of the situation, the magic buzzing around them. But this tactic had the effect of forcing Sam inside of his mental image of himself, looking through imaginary Sam's eyes rather than watching him kill the wolf from above. He felt the same emotions that he would if he were faced with an impersonation of his brother-- a shapeshifter, or a hallucinated version of Lucifer pretending to be Dean.
This tactic had hit a nerve. He reached for anger, felt it boiling up: how dare someone else try to be his brother, try to use that against him. Anger gave him strength, making him think more clearly, like a hunter; made him reason his way through this. His brother would never grab the gun barrel like that. He would hold up his hands in surrender and talk Sam down, or he would actively disarm him, he wouldn't just shove it away. It took more than just looking like Dean to be Dean, but it was also more difficult to find the will to shoot something with his brother's face on it.
A memory surfaced, but instead of just watching it play out, Sam brought it to the surface: he imagined himself facing off with the shifter with his brother's face, and then his own visualization of Dean stepped through a door from his memory to the current battleground, and shot his doppelganger twice in the chest with silver bullets.