Why do schools have so many secret passages
Because you're in Hogwarts.
For emergencies I guess...
Schools have many secret passages in case of danger. These passages are the ones used when there is unrest in school or danger. They are used as escape roots where the enemy cannot know.
It's where the teachers took the bad kids for punishment in the good old days when a teacher still had rights