After a century of suppressing radical Muslems it’s a very really possibility that Erdogan’s is struggling to be seen as radical enough for the blood thirsty zealots.
Erdogan may soon instigate a foreign conflict, point to a foreign enemy, just to now stabilize the situation within Turkey.
First part is true the Turkish leaders have been trying to keep the fundamentalists out of power. But it could be that Erdogan is trying to change that policy especially beneath the surface and the coup was an attempt to stop him from bringing fundamentalists to power.