Afghans haven't been kicked out, barely a few hundred thousand were deported in a sea of millions. I seriously doubt Pakistan even has the ability or will to locate and deport all.
I am the first to criticize Pakistan on its chronic incompetency issue. But you are making false equivalents here.
Not every form of militancy is the same in nature, not every form of militancy has the same level of grassroot support, and not every militancy has the same level of foreign backing. Hence comparing these is foolish.
What's really disappointing, as you stated, is that we don't see the will on the Pakistan side to tackle it with full aggression using all force and intelligence at disposal by the state.
Pakistan's militancy is naturally far far more potent than most other places in the world due to
-Porous western border which is **incredibly** hard to monitor 100% and have full control over.
-Lots of underdeveloped tribal regions that do have an organic leaning towards what the mainstream would describe as "extremist tendencies"
-A huge Afghanistan next door, with no infrastructure, and a hotbed of terrorism and extremism, with the Taliban in power who sees the TTP as essentially blood brothers.
- Militancy amped up in potency by funding from India as it's an easy way to destablise their adversary.
This is a bit like Turkey's situation with the Kurdish insurgency - except at least Turkey's neighbours are co-operative in helping it against militancy and Turkey is far more aggressive, more competent, and more funding at its disposal.