Force is linear, energy is quadratic
A spring is the cleanest energy store in mechanics: squeeze it, it pushes back; let it go, it gives the energy back. Two relations govern it and they are NOT the same relation, which is where every mark gets lost.
Hooke's law gives the force: , read aloud F equals k x. is the spring's force in newtons; is the spring constant, or stiffness, in newtons per metre — how many newtons it takes to move it one metre; and is the displacement from the spring's FREE length in metres, compressed or stretched, the relation does not care which. Force is linear in : twice the squeeze, twice the push, every time.
The energy stored is — U equals one-half k x squared, in joules, with the same and the same . Energy is quadratic: twice the squeeze, four times the store. And the half has a reason. The spring's force starts at zero and climbs to , so the work you pay is the AVERAGE force times the distance — which is exactly . It is not a fudge factor; it is an average, and you have just derived it.
Keep the units as your referee. is N/m, so is N/m × m = N, a force. And is N/m × m² = N·m = J, an energy. If you ever hand in a spring force wearing joules, that check would have caught it before the marker did.