The more we learn about the Turkish coup, the more improbable it seems that the coup was staged, since it seems clear that the attempt was real. It does seem possible, however, that the government had gained some prior knowledge of the coup plans, allowing it to outmaneuver the plotters. The Air Force was clearly involved, and the Navy's role is unclear, with some naval vessels reportedly unaccounted for.
But the sheer scale of the purges goes far beyond the actual participants in the coup, including some 35,000 people from the military, government officials, and academic institutions. If all these people were involved in planning a coup, it would have succeeded. Clearly the government had a target list ahead of time.
Why it failed is still being debated, but my suspicion that the government had foreknowledge of some sort seems likely, given the fact that President Erdoğan evaded capture despite a reported assault on his hotel, and that the plotters were unable to take key command centers in Ankara. The failure to seize private broadcasting centers (which are more popular than the state-owned media) has been much remarked upon. Clearly, the coup failed to ensure sufficient unanimity in the chain of command. Its execution was a disastrous mess.
The what-went-wrong argument is interesting and I may have more to say as we learn more, but clearly the excessive purges have rapidly become the main story.