Turkey have a region where most people are Kurds. For hundreds of years, The Kurds had been a target of discrimination and violence in the middle east. The Kurds are the biggest population on earth to have no own country. There are Kurds in Iraq,Syria and Turkey.
The Syrians, Turks , Iraqis and Kids were currently in the same side against ISIS but the Turkish Army seems the Kurds who actually defended their people instead of Isis members. The Turks find the Kurds a bigger threat than ISIS because they were afraid that Turkish residents of Kurdish decent may ask for independence. Rather than setting aside differences and work together to defeat a common enemy the Turks decided to make things complicated.
By the way President Obama asked the Turks to stop attacking the Kurds: