The military has ruled Pakistan off and on since its birth following the British abdication in 1947, actually more "on" than "off." The army is probably the most honored institution in the country. We shouldn't be surprised that it takes over when things turn really ugly, as they often do.
This article in the Telegraph (UK) argues that the Pakistani army is not showing interest in once again taking responsibility for the government. I think that could change fairly rapidly.
A long article in National Interest lays out the entirely dysfunctional nature of Pakistan. Read this if you have some time and really want to get down into the details of the Pakistani dilemma.