Alfred the Great became the king of the Anglo-Saxons by first becoming king of the West Saxons. He became king of Wessex when his brother, Ethelred, died in 871 AD.
But this did not make Alfred king of all the Anglo-Saxons. He earned this title through battle and through diplomacy. Alfred's most important military exploit was his defeat of the Viking army that was trying to expand and make permanent the Viking holdings in England. After that, Alfred used diplomacy to gain the support of the other Anglo-Saxons in that part of England. He then set about creating a more united political entity that would later be able to repel further Viking attacks. In these ways, he became important enough that he was able to call himself King of the Anglo-Saxons.