The key thing to grasp here is that Erdogan lost a complicated game, but managed to save face. Turkey had to abandon nearly all the objectives of its Syria campaign, accepting just a fifth of the “gains” it wanted. Erdogan won control over just a small piece of Kurdish territory, losing any hope to expand this zone to a 19-mile strip of land along the entire border, which was the military's minimum objective. (Turkey had even entertained the possibility of occupying the entire northeastern third of Syria.)
Erdogan failed because he
forgot the rules of modern “hybrid war”; Turkey didn’t pair the invasion with the necessary diplomatic and media cover, and it went to war with bad allies.
Almost effortlessly, the Syrian government and Russia gained the right to take control over almost a third of Syria’s territory, which until recently was in the hands of Kurdish politicians and their American allies. This was possible thanks to the withdrawal of American and European troops, which Damascus and Moscow sought unsuccessfully for years, and Recep Tayyip Erdogan finally achieved.