From the point of view of the villagers, Hanz would have looked like a good leader in the absence of both Elsa and Anna (as appointed by Anna before she left). The villagers don't really know that he is the villain. The viewers know because of the dialogue between him and Anna before he leaves her to die, but the villagers are still ignorant to that. So my question is: why did the villagers clap when Anna punches him out during the final scenes of the movie?
It's not really clear but it's possible because they heard him lie about Anna being dead....on more than one occasion.
He tells the nobles (who are the ones applauding) that Anna is dead in the meeting room..
HANS: Princess Anna is...dead.
DUKE: What happened to her?
HANS: She was killed by Queen Elsa.
DUKE: Her own sister.
HANS (really putting it on): At least we got to say our marriage vows...before she died in my arms.
...and again, he tells Elsa on the frozen harbour...
HANS: Your sister? She returned from the mountain weak and cold. She said you froze her heart.
ELSA: What? No.
HANS: I tried to save her, but it was too late. Her skin was ice. Her hair turned white...
Elsa’s face sinks as she realizes what she has done.
HANS (CONT’D): Your sister is dead... because of you.
As he then moves to kill Elsa, Anna appears and saves Elsa thus putting the lie to his words and invalidating any good impression that he might have given before.
It's kind of hard to see but you can see them on the castle balcony in the distance when the storm subsides.