The spring-mass system is a SHM because its motion can be described by one single sinusoidal function.
Some of you may be curious why SHM is given such an exotic name. Actually, it comes from mathematicians’ knowledge that any periodic function can be described as a summation of many sinusoidal functions of different frequencies, or harmonics.
For example, the periodical rectangular function (drawn in red) can be constructed by summing five harmonics (drawn in blue). If you want a more perfect rectangular function, more sinusoidal functions of higher frequencies, or higher harmonics are required. If you’re interested, Discrete Fourier Transform is how one can solve for the harmonics of any periodic function.