In addition to the points raised in answer 2, the Pakistani government also has faced a number of domestic problems, notably with terrorism. These issues can be used to justify militarism as well. But ultimately, it is the presence of India on its border and the repressive nature of the regimes themselves that have led to its development as a militaristic state.
I would say that the militarism of Pakistan comes from two sources. First is the fact that it has always bordered a country that it sees as a mortal enemy. Second, it has never had a really strong democratic government. For these reasons, the military can come to seem indispensable.