A few months back, when President Recep Tayyip Erdogan finally decided to allow US warplanes to fly sorties from Incirlik, it was fairly obvious what what was going on. Erdogan had just lost his absolute majority in parliament which is a bigger deal than it might sound. That majority was critical for Erdogan in his bid to alter the constitution and consolidate his power. Adding insult to injury, the AKP's lost ground at the ballot box was partially the result of a strong showing by the pro-Kurdish HDP. Given the, how shall we say, "contentious" relationship between Ankara and the PKK, that was a bitter pill to swallow.
So, what Erdogan did, is effectively start a civil war by reigniting the conflict with the Kurds. This was done under the guise of a "war on terror" (and when you think about it, what isn't done under the guise of a "war on terror" these days?) and NATO gave its blessing in exchange for access to Incirlik and a (largely fake) promise from Erdogan that part of his war would be focused on ISIS.
For Erdogan, the idea was to stir up fear amongst the populace in an effort to boost support for AKP. Once that plan was put into motion, he then moved to stymie the coalition building process. Once he had sabotaged that completely, the path was clear for him to call for new elections.
In short, this was a gambit to subvert the democratic process by stoking violence which Ankara hopes will lead to stronger support for AKP at the ballot box in November. That, in turn, would pave the way for Erdogan's power play. Thanks to the fact that Erdogan is a US "ally" in the war on terror, this whole thing gets the Good Housekeeping seal of Western approval.