In the case of the US, the presence in America of President Tayyip Erdoğan's one-time Islamist ally, now rival, Fethullah Gülen has been an irritation to Erdogan for years already, since the political split between the two leaders in 2013.
One of the many US military bases overseas is in Turkey at Incirlik Air Base, which the linked article at Global Security describes this way (n/d but includes information on the coup attempt; accessed 08/05/2016):
The attempted coup in Turkey on 15 July 2016 resulted in unexpected national security concerns for the United States. The purportedly spontaneous uprising called into question the security of American hydrogen bombs currently stored in a Turkish airbase. Located in southeast Turkey, the Incirlik Airbase includes NATO’s largest nuclear weapons storage facility. The American embassy in Ankara issued an "Emergency Message for US Citizens,"on Saturday morning, cautioning that “local authorities are denying movements on and off of” Incirlik and that power had been cut. US Air Force planes stationed at the base were prohibited from taking off, and the airbase had to rely on backup generators for power. The threat level reached FPCON Delta, the highest alert, usually declared after a terrorist attack or if an attack is deemed imminent.This air base has been used for US operations against the Islamic State (IS), the Islamic rebel/terrorist group with whom we are not officially at war.
The base commander, General Bekir Ercan Van, along with nine other Turkish officers, was detained at Incirlik on Sunday for allegedly supporting the coup. American airbase flights have resumed, but power has not been restored. [US European Command reported on July 22 that power had been restored.]
Hans M. Kristensen, director of the Nuclear Information Project at the Federation of American Scientists, claims that the Turkish airbase contains about fifty B-61 hydrogen bombs, more than a quarter of all the nuclear weapons in the NATO stockpile. What separates the B-61 from other weapons is its ability to adjust nuclear yield. The bomb dropped on Hiroshima, for example, had the impact of roughly fifteen kilotons of TNT. The adjustable yield of the bombs held at Incirlik can range 0.3 to 170 kilotons, making for a more versatile weapon.
Turkey's interest in the Syrian civil war is primarily aimed at preventing a strengthening of Kurksih power and in overthrowing the Syrian regime. The US focus in theory is more on fighting the Islamic State (IS) than in overthrowing the Assad regime as such. Turkey has also opposed the IS. (Beat Ammann, Eine immer schwierigere Zweckbeziehung Neue Zürcher Zeitung 20.07.2016) But since the coup, Turkey appears to be trying to improve its relations with Assad ally Russia.
An section titled, "Der Neo-Sultan," in article titled „Trump, Türkei, Brexit, Terror - Warum spielt die Welt verrückt?„ Profil (print edition) 25-07-2016argues that the internal situation in Turkey also can't be understood without taking into account the Kurdish conflict.
There have been protracted efforts over years to arrange an eventual entry of Turkey into the EU, efforts which Erdogan activlelysupported until recently. That has involved closer economic relations between Turkey and the EU, the latter being Turkey's most important trading partner. It has also involved Turkey adopting the Charter of Fundamental Rights of the European Union. The post-coup actions of Erdogan's government raise new questions about Turkey's longterm seriousness about their adherence to the Charter. Erdogan's current push to restore the death penalty in the wake of the coup is already a looming issue that would push Turkey even further away from prospective EU membership.
Angela Merkel's refugee policy requires cooperation from Turkey. The current arrangement involves Turkey holding immigrants in Turkey and preventing them from moving on to EU member countries.