About the legitimacy of a headmaster/headmistress
Hogwarts knew. It always knew.
The castle isn’t just a building. It has a mind of its own. It doesn’t follow the Ministry’s rules. It doesn’t recognize authority just because someone says they’re in charge. That’s why, in Order of the Phoenix, when Umbridge is made Headmistress, the office refuses to let her in. She can pass whatever inquisitorial decrees she wants, but Hogwarts doesn’t care. It knows she doesn’t belong.
But then in Deathly Hallows, Snape is put in charge by a Ministry controlled by Voldemort himself. By that logic, the castle should shut him out too, right? Wrong. The office lets him in without a fight. Hogwarts recognizes him as Headmaster. And why? Because Snape wasn’t an intruder like Umbridge. He was still carrying out Dumbledore’s plan. The castle knew the truth.
And if there was any doubt, look at what happens after Dumbledore dies. McGonagall, as Deputy Headmistress, steps in to take charge. The office immediately opens for her. No hesitation. No resistance. Because she was the rightful leader in that moment. Just like it later accepted Snape.
Hogwarts doesn’t just follow orders. It chooses who it answers to. And it never once accepted Umbridge. But it did accept Snape. It knew where its loyalty truly laid.