It’s not totally clear. There were probably always some Muslim Turks in Central Asia, along with Christian and Jewish Turks, and Turks who still followed their original pagan beliefs.
But if you mean, why are Turks usually Muslim today, then it's because Seljuk, the ancestor of the Seljuk Turks, converted to Islam in the 11th century. Why did he convert? That's also not clear. Supposedly he was simply divinely inspired to convert, but he must have seen some social or military benefit to joining the religion of his powerful Muslim neighbours in Persia. Before converting, Seljuk and his family may have been Christians or Jews (since his children all had Biblical names).
Seljuk’s conversion inspired the other Turks to convert in the 11th century as well, but “our understanding of the spread of Islam among the Turks in this period is very limited” (Peacock, pg. 247). Not all of them converted at the same time, and there were still pagan Turks in Central Asia in the 12th century, but they were eventually all Islamized.
The type of Islam they encountered in Persia was Sunnism, and the Seljuks became known for their devotion to Sunnism and their opposition to Shi'ism.
“The Seljuks are traditionally characterized by their avid support for Sunnism. This formed a key part of Seljuk propaganda, and even today continues to influence scholarly and popular perceptions of the dynasty.” (Peacock, 249)
It's probably not exactly that simple - they were supporters of some branches of Sunnism, but not others, just like they supported some branches of Shi'ism, and not others - but in any case, the Seljuks were responsible for spreading Sunni Islam east into Central Asia, and west into Anatolia when they invaded the Byzantine Empire.
Source:
A.C.S. Peacock, The Great Seljuk Empire (Edinburgh University Press, 2015), especially chapter 7, "Religion and the Seljuk Empire"
Nicholas Morton, "The Saljuq Turks' conversion to Islam: the crusading sources", in Al-Masaq: Journal of the Medieval Mediterranean 27:2 (2015), pp. 109-118
Well it was not happen in a short time . Took couple century. Turks were also mentioned by
prophet Muhammad ( pub.) As (Etrak) like hadith (saying of Muhammed) "Leave the Turks alone, as long as they leave you. " which was turning point for many years to leave the Turks alone. But after Umayyad Caliphate , time turkic or turks were like pretty much every other nation , under attacked by Arabs and killed. ummayyad cruel action postponed spread of islam in turkic peoples. Because Ummayyad first intention to make slaves and taxation of the Turkic or Turks never succeeded bring stability in both sides.
But during Abbasid time Turks begins to learn Islam. Also Turkic (turks) tradition of Warrior nomadic lifestyle played great role here.
One of the interesting and misunderstood by western is the Turkic tengrism. Because so call shamanism or paganism definitions is pretty much wrong in multiple ways.
According to old turkic tengri in many sources it's diffrent from mongol tengrism. Such as Everything including so called deitys Turks called Ruh(spirit or or beings) are created by one (Tengri or Koktengri) Turkic word for God. He created the world and yersub give many spirits living things to world and the Turks are the rulers. children's by the tengri self.
So in ancient time Kut almak (tengri given titel )is shanyu(modu shanyu first used in history) is pretty much the same reason.
As we know that Mongols who were called dongh-hu and lived forest culture in eastern mongolia and western manchuria seen many adapter of tengrism differently . because of the animalistic and polytheistic culture of mongols are the one of the longest neighbour of the Turkic(turks) people . They probibly learned the tengrism after around 150BC when modu chanyu destroyed and conquered Dong-hu, also ancient tengrism of mongols pre 14 century does differences with today to. Because of the buddhism effects.
For example in mongol tengrism (Umay) seen as god. while orchun inscriptions(oldest turkic survived texts) says : umay is created by the tenrgri and power had to given by the tengri self. Also Umay used as Meteforic meaning gives a good understanding that Turkic(turks) tengri is more monotheistic character with many spirits and living things. turkic tengrism Kam (god hand , shaman ) never had a power more like medicine man living in poverty in the tribe. But mongols or later influenced siberian turkic (Kam) have role fortune tellers. Or more like highly ranked person. But men not forget that Turkic peoples lived as clan base nature that and living larger area they somehow become more isolated to other clans and have differences in tengrism ideology too. Which can be see altaic tengrism.
As for Turks They were called Oghuz ok-uz,us(ARROW-PEOPLE) on of the oldest diary written by Arabic travel Ibn fadlan who also seen Vikings : saw the the Turks (Oghuz)before they were muslims and he says : "when something happens: they say 'bir tengri' one God... fornication was also forbidden among the Oghuz , person who giving words must be keep it, including hospitality" but he also says that some bulgar turk onghur- volgabulgars were muslim at the time so gives a pretty much that at 9 century turks from western side were not muslim at at all. But when abbasids new politics to spread islam not by war. And most importent being muslim gives a less taxes is major reason, another thing that gives prestigious titels to turks in the abbasid and also Talas war in 751 made the turning points for turks. Which gives the opportunity for turks to learn islam and if one leader converts pretty much the whole clan converts because of the turkic tradition and way of respecting their leader. Also learning the similarities with islam. Gazha and fatih (conquering fighting for holly religions) is perfectly adapted to the Turks. Imagen every born person in Turkic clan born to fight including Women . And children begins to learn very early age gives a Turks a huge advantage in conquest times. Another facinating thing. is it's know to that living places and life style made the Turks never have pig farming or pig related things. Because domesticating pigs or boar need more forest or not steppe like places . pig can not travel long distance made the turks never farming pigs.
Even old times pig considered by turks dirty which some historians says " manchurian tunguz dongu(ancestors of mongols) tomuz, domuz, tunguz were called by turkic people because they have pig , boars"
So pretty much you can say that from 6 to 7 centuries turks(oghuz) from 8 to 10 centuries not all Turks were muslim but begins to convery. . around 10 centuries, majorities were muslim under seljuks..... but even seljuks were many people had a tengrist traditional. Even some seljuks dynaties you see many tombs still had tengrism. And another misunderstood thing. When seljuks conquered anatolian they begin to use 2 headed eagle but that is pretty much wrong. That is Tugrul - konrul birds 1 represents east other represent west. Which is weather HUNs when they break up and march to Europe used TUGRUL bird sembol of hungarian today. If you look at the flag of seljuks 2 head binds with brace represent unity. And ruling sembol. so as for Turks. As for new converts they matured durinh ottoman times.