1. The country of Turkey was founded a century ago as a secular state, the military is the bastion of secularism.
2. The current dictator is moving in a religious direction, from allowing head scarves to saying people from religious schools knowing nothing but the Koran can go to college or hold public school teaching jobs. End result - erosion of secularism.
3. He was revealed to be supporting ISIS to attack Kurds, who are more liberal than most Iraqis and western Turks. He wants them to attack the Kurds in the western part of his country and northern Iraq, because he's afraid Kurds will try to unite into a new, Kurdish nation.
4. He's been suppressing the liberal secular Turks protesting since at least 2013, saying he can ignore it because he's following Allah's will. Democracy dies when the leader can say he's doing the deity's will.
5. The secular military was trying to overthrow the dictator both on the basis of his ignoring the will of the people and the underlying secular nature of the state.