The restoring force is electromagnetic in origin, having to do with atomic/molecular interactions.
Both electrostatic as well as magnetic forces vary inversly with the square of distance.
$F_{_{EM}}\propto \cfrac{1}{d^2}$
So why does the restoring force vary directly with the length of the spring?
$F_{s}\propto x \implies F_{s}=-kx$
PS
In this question it has been said that applying force on the object does try to displace atoms away from each other so electromagnetic forces should reduce.