Why does simple harmonic motion occur?
If an oscillating system has a restoring force that is proportional to the displacement which always acts toward the equilibrium position.
Simple Harmonic Motion (SHM) is defined as an oscillation whose restoring force is directly proportional to the displacement and always acts toward the equilibrium. So if an oscillation meets that condition then it is simple harmonic.
If the mass of the object is constant then
A horizontal mass spring system will undergo SHM. The restoring force is given by