The entire thing was staged by Erdogan to secure his political power, remove everyone he doesn't like from office in one fell swoop and replace them with hand-picked goons, and remove every last remaining fabric of democracy from Turkey.
The only coup here is the one Erdogan started himself.