This entire attack was in retaliation to violence by the Pakistani army in the first place. You do not stop violence by retaliating with violence. You do that and the Taliban will plan something else bigger in response. End the pointless cycle of killing, that's what the Pakistani army needs to do.
The problem is that they've shown time and time again that they won't respond to any type of bargaining or peace talks. This attack also shows that they're willing to go to extremes to get their point across. The army is stuck in a position where if it doesn't do anything, innocents die. If it does something drastic, innocents die.
Another thing is the fact that these people aren't just a bunch of radicals holed up in underground caves in specific locations. These people are EVERYWHERE in the country, including the metropolitan areas in the big cities like Lahore,Karachi etc. They get recruits from Islamic schools called "madarsas". If the education system and the poverty was under control, people would just send their kids to regular school, instead they often just send them off to madarsas which brainwash a lot of these kids and teenagers, and then turn them into willing agents that carry out these attacks.
It's going to take nothing short of a MASSIVE show of force to get the Taliban to back down, even if temporarily. Then you run the risk of them increasing the frequency and caliber of their attacks.