Military answers to whomever it thinks it's best to get paid. If relationship between government and the people fails so hard that collection of taxes to fund the military is threatened then the military sides either with the people and deposes the government or with the government and suppresses the unrest.