My experience with military officers from that neck of the woods - i.e., the Muslim Mediterranean - is that they regard themselves as the guardians of secular government and are extremely leery of "crazy beards" (as one Algerian major described them to me) becoming too influential. That's probably at least in part to what happened in Iran - the mullahs take over and all the 'westernized' soldiers find themselves hanging from trees or running for Paris. And remember that in most of that world, being a military officer is a family affair, almost a social class more than a professional class. The Turks take it even further, with Ataturk's philosophy that Islamism is actually a hindrance to progress that should be suppressed, as opposed to just controlled or contained.
Erdogan's been playing with fire for a while now, marginalizing the military, suppressing democratic institutions, and flirting with Islamists, in a country where those are all things that piss off the guys with guns. I'm surprised it took the army this long to move, frankly.