IK went against the very people and organizations that helped bring him to power. He likely also knew this since his younger days but cricket glory , popularity and international fame blinded him and he likely thought he achieved all that popularity and international fame on his own without focusing on who all he was getting into bed with.
He could never have won the Pakistan elections on his own without the strategic backing of the establishment and the agencies. They wanted him in with certain objectives in mind, but once he became PM, he started drifting away from those.
Once in power, he saw the complete picture that he had been used as a pawn, placed there not really for his leadership, not for his popularity, and definitely not for his past work. Those were just the surface reasons, the facade to get him elected.
IK realized how deep things really went and turned against the establishment, the agencies, and most importantly, the US and Western apparatus (the playground for Satan's darker forces).
They and the establishment responded by empowering the opposition, getting him ousted, and then throwing him in jail. The Pakistan establishment's hands were tied as it was either align with the US side or risk the country's stability. So they made the pragmatic move and helped put him behind bars.
He could easily have been eliminated, but that would have shattered the country's fragile stability. Plus, given his massive popularity, there might have been longer term plans to bring him back into line later, release him to calm public sentiment, and still steer him toward their goals. Apparently, he hasn't given in.
Never treat Shaytan as something to use or leverage against others as that's exactly what he desires. He acts humble to draw you in, then slowly takes control by exploiting your weaknesses and the sins you have committed. He dangles power, money, and fame in this world, but the moment you turn pious, noble, and truly Allah fearing, he becomes your focused enemy. Shaytan was already your enemy from the day you were born, but if you briefly befriend him and then reject him for Allah's sake, his hatred intensifies. He'll try his utmost to inflict pain not just on you, but on everything your ideology stands for and the people who follow your path.
Only by Allah's will and protection can someone be safeguarded from Shaytan's harm, even if it's a cat that devoured a thousand mice and then performed Hajj. As long as there is true repentance.
I pray for Allah's justice to prevail and for IK's health, a just release and peace to the people of Pakistan.