1 Samuel 12:12-13 NASB
[12]When you saw that Nahash the king of the sons of Ammon came against you, you said to me, 'No, but a king shall reign over us,' although the Lord your God was your king. [13]Now therefore, here is the king whom you have chosen, whom you have asked for, and behold, the Lord has set a king over you.
The children of Israel had already asked for a king well before the threat of Nahash
1 Samuel 8:4-5 NASB
[4]Then all the elders of Israel gathered together and came to Samuel at Ramah; [5]and they said to him, "Behold, you have grown old, and your sons do not walk in your ways. Now appoint a king for us to judge us like all the nations."
Samuel had already anointed & proclaimed him king at Mizpah before there was any threat from the ammonites
1 Samuel 10:17,24 NASB
[17]Thereafter Samuel called the people together to the Lord at Mizpah; [24]Samuel said to all the people, "Do you see him whom the Lord has chosen? Surely there is no one like him among all the people." So all the people shouted and said, "Long live the king!"
So why does Samuel say that it was the threat of Nahash that galvanised them to seek a king?