As JM noted it is in essence the same word for two distinct groups. The Cossacks originated as Tatar mercenaries called ( what else ) Kazaks, ‘free adventurers’ that were used to garrison forts along the Dnieper by the Lithuanian Grand Dukes from the early 15th century. To these were added various fugitive peasants and outlaws and they soon morphed into a distinct ( and eventually largely Slavic ) community that largely adopted the steppe habits of of their Tatar antecedents and neighbors. As Muscovy expanded and collided with Lithuania they eventually became an essentially autonomous marcher society that could sway the balance of power between the two. In a manner very vaguely reminiscent on the American West they functioned as a societal relief valve ( only in this case more often they were fleeing tangible repression such as serfdom ) in a rugged marcher region ( at least until the fall of the Crimean Khanate in the late 18th century ). They eventually existed as seperate hosts ( Don Cossacks, Zaporzhe Cossacks, Yaik Cossacks, Volga Cossacks, etc. ) corresponding to their approximate ranges.
The Kazakhs were formed as the result of a political split within the Uzbeks. One of the grandsons of Chingiz Khan was one Shayban ( variously spelled ), a younger brother of Batu, founder of the Golden Horde. He performed very well in the European campaign and was to have received the Hungarian plain as his appanage if fate hadn’t intervened with the death of Ogedei and the retreat of the Imperial home army, causing Batu to pull back and consolidate on the Qipchak steppe ( southern Russia ). Instead he received an appanage in the far east of the Khanate in westeren Siberia. Jump forward a couple hundred years and the White Horde of what is today Kazakstan ( another appanage of the Golden Horde, in this case of Batu’s unambitious elder brother Orda ) re-merged with the Golden Horde as the Whitre Horde’s new Khan Tokhtamish ( a disciple of Tamerlane ) assumed control of the Golden Horde. As part of this new transfer of power the nomadic White Horde migrated off the Kazakh steppe westwards to physically combine with the Golden Horde. The Shaybanid horde, which at some point had taken the name Uzbek ( Ozbeg ) ( probably in honor of the Golden Horde’s greatest Khan after Batu, who had converted the GH definitively to Islam ), now migrated into the suddenly vacated Caspian steppe country to the south.
Now…under the Shaybanid Abu’l Khair ( who Grousset referred to as a “failed Chingiz Khan” ) they expanded southwards conquering most of Khwarizm and Transoxania to create a very large empire. But in 1456 or 7 he was invaded and badly defeated by the Oirats ( West Mongols, from which the later Dzungars sprang to create the last of the nomad empires ) and in the ensuing chaos two sub-leaders ( both also princes ), Qarai and Janibeg, rebelled taking with them a substantial portion of the Uzbek’s nomadic population, swearing allegiance to the Chagataid Khan of Moghulistan. Eventually they shed all authority ( and killed Abu’l Khair when he attempted to forcefully reintegrate them ) and became a purely nomadic polity on the Caspian steppe divided into three divisions ( the Little Horde, the Middle Horde and the Great Horde ). And they took the name Kazakhs ( ‘free men’, ‘free adventurers’ ) :).
- Tamerlane