When Konohagakure is attacked, the leaders has a plan for protecting the citizen, splited into three stages.
When an enemy attacks, Kohona ninjas eliminates all intruders.
If the enemy can't be immediately eliminated, the Konoha ninja goes to stage 2: evacuate all civilian. There are several places in Konoha where the civilians can be safe, among others inside the Hokage mountin. In order to protect the civilians, some lower level ninjas fights the enemy.
When all civilians are safe, all Konoha ninjas are used to eliminates the enemy.