more than 90% of Turkey's people are muslims so having a muslim party ruling is not a big surprise. The thing is people in Turkey are mild about religion, we do not care that much about religion and It's almost impossible for Turkey to be an Iran one day. You may ask then why is Turkey backing Iran nowadays ? It's simple, having an isolated and problematic neighbour might be a big problem for Turkey and if it's a big country like Iran you might need to be even more cautious ! Turkey is trying to have an affect on Iran, trying to push these countries be a part of the international community (Iran, Syria, Iraq) because it's in best interests of Turkey. Turkey is saying to itself : "whether you like it or not, Iran, Syria, Iraq are gonna be your neighbours, and having economically developed and not isolated neighbours is a better option " At the end, who wants a fire out in neighbour's house ?
U.S., allies conduct 31 air strikes in Syria and Iraq against ISIS militants (Reuters)