One of the reasons that Pakistan has so many problems with Islamic terrorists is that its special Anti-terrorism Courts (ATCs, established in 1997) release most of the suspects the police bring in for prosecution. The ATCs blame the police for not having sufficient evidence to justify a conviction. Apparently many suspects are released before trial for this reason. Less than 20 percent of arrested terrorism suspects are convicted. About half of the arrested are given bail, and many of them just disappear. Some reappear when they are once more arrested for terrorist activity.
Many cases don't result in conviction because witnesses are threatened by terrorists, and refuse to testify. There are also occasions where bribery is used. In some parts of the country, less than five percent of terrorist arrests result in a conviction. All this is apparently fine with the politicians, who can have it both ways. They can point to arrests and laws passed against terrorism. Yet they avoid personal harm by pandering to terror groups by not locking up lots of terrorists. The only terrorists who get jailed are those who are unlucky, or who have pissed off their bosses.
This kind of arrangement with terrorist groups is common. Many European nations have been accused of using it (not officially, but in practice it's pretty obvious). It's been quite common throughout the Middle East for a long time, so it should be no surprise that Pakistan plays by these same rules.