LAHORE, Pakistan—Nawaz Sharif was in prison ... The reversal of fortunes reflects the roller-coaster ride that is Pakistani politics and the influence of the country’s powerful military.