In a nutshell
K-means sorts unlabeled points into k groups without being told what the groups are. It places k centroids (group centers), assigns every point to its nearest centroid, then moves each centroid to the average position of the points it captured. Repeating these two steps sharpens the groups until nothing changes — though the result depends on where the centroids started, so it finds a good grouping, not always the best possible one.