Another way of looking at is:
SHM is where a restoring force always acts towards the origin. So when x is positive the force has to be in the negative direction, when negative the force has to be in the positive direction.
The acceleration will be in the direction of the force.
So when x is positive the force is negative, when x is negative the force is positive.
For acceleration = - const X x to keep the minus the constant MUST be positive. That means it must be a square (guaranteed to be positive).
More generally when you require a real quantity to be positive - express it as a square i.e x2
When required to be negative - express it as the negative of a square i.e. - x2