Let's not spread biased propaganda - Turkey is not helping ISIS. It is only prioritising its own political interests.
The Kurds are an ethnic group, predominantly muslims with their own cultural and linguistic traditions. After Word War 1, European powers promised the Kurds their own country in an agreement known as Treaty of Sèvres. But the subsequent Treaty of Lausanne rejected the Kurdish right to self-determination and they were instead divided among Turkey, Iraq, Syria and Iran. Half of the 30 million Kurds today live in Turkey. In an attempt to assimilate the Kurds into their society, Turkey has followed a political policy of giving prominence to Turkish culture while de-emphasising the Kurdish culture and language.
Due to these historical and political reasons, a section of the Kurds feel resentment and continue to advocate for a separate country of their own. Turkey fears that this will lead to a partition of their own country if the demand for a new homeland for the Kurds finds international acceptance. Turkey has thus been suppressing such political demands from the Kurds. It has felt justified about this since some group resorted to violence and terrorism. The Kurdistan Workers' Party (PKK) is one such group that has fought for Kurdish autonomy in Turkey and has regularly launched attacks across the country in the name of Kurdish nationalism and killed tens of thousands of people - it is designated as a terrorist group by the US and EU.
The US, in search of more allies in the middle-east, has tried to win over the Kurds there. They even allowed Kurds in Iraq to form their own autonomous government in a region of Iraq - something that Turkey hasn't appreciated as it creates an international precedent that Turkey fears could be used against it to one day.
Moreover, the US also recruited Kurds - the People's Protection Units (YPG), the military wing of the Kurdish Democratic Union Party (PYD) - into its alliance of Kurds and Arabs, called the Syrian Democratic Forces (SDF), to fight the jihadist group Islamic State (IS). The Kurds lead SDF successfully fought and captured a lot of territory in Syria, from ISIS and has also sought recognition for Kurdish autonomy in Syria.
This has again unsettled Turkey, as it doesn't want another region, in another country, to emerge as an "autonomous" Kurdish region. Moreover, the Turkish government is convinced that YPG in the SDF is an extension of the Kurdistan Workers' Party (PKK) and the US arming and training them threatens Turkey's internal security. Turkey is convinced that the Kurdish fighters in Syria are now assisting the PKK in Turkey to renew their demands for an autonomous Kurd region in Turkey.
That's one part of it.
The other is that the conflict in Syria has meant that Turkey has had to accept millions of Syrian refugees into its country. And this has created a lot of political tensions in Turkey, especially with a weak Turkish economy (which some political opponents, have unfairly attributed to the Syrian refugees). There have been demands that Turkey send back these refugees elsewhere, and seal the Syrian borders to prevent the influx of further Syrian refugees into Turkey.
Thus Turkish leaders, both due to future security threat from Kurds in Syria, and present political compulsions of dealing with Syrian refugees decided to create a 400+ km long "safe zone" across the Syrian borders, fortified especially where Kurds are present and also attack the Kurdish-captured areas in Syria. They then planned to "relocate" the Syrian refugees back to these areas which the Kurds currently dominate.
To make a long story short, the Kurds in Syria could not deal with the Turkish and Syrian rebels' military onslaught. As the Kurds felt betrayed by the US, they decided to form an alliance with Syria's leadership (who the US is fighting). Russia further stepped in brokered an agreement between all four parties in the region to reduce conflict:
Sources:
- Washington Post - Who are the Kurds, and why is Turkey attacking them?
- BBC - Turkey v Syria's Kurds: The short, medium and long story