I think your speculation is pretty good. Some fraction (top to bottom) of the military was fed up, and had nothing to lose.
ISIS has won. Turkey will become an Islamic theocracy. Too bad for the Turkish people and the rest of us.
Gulenist faction accusation is cover to get the Turks on Erdogan’s side. He said that while out of the country when he was not sure of the extent of the coup to get a popular uprising against the coup....it’s all not true....this was a small fraction of the military coup that hoped the rest of the military would join in and the did not...
Perhaps Erdogan staged a face coup. That would flush out the military (and others) who did not support him. Just in time for the August changes.
Certainly a possibility.