I'll never understand calculus, but I understand this.
Spring force F = k * x, which is the equation of a line, y = m * x + b. m , k are constants, the slope of the line. x is the displacement, dimensions of length. b, the offset, b = 0 for the spring. It's linear, freshman year HS.
But you don't want to know the force F, it doesn't tell you what you want to know. That they do teach it this way proves my point, the book is wrong.
The high order skill is to look at the system and write the equation for it. From there the computer will solve it or you can Google for the solution to the equation.
First step in the book method is to disassociate the problem from the model so the math becomes unrelatable or unrecognizable, producing hordes of people who get lost at that point (thrown from the cliff more like it).
Forget about the force balance equation. Look at it and set it up as the Conservation of Energy Law. Total Energy = Potential Energy + Kinetic energy (+ losses = 0). The potential energy of the spring is the integral of force over distance (calc term), which is area under the curve, for that case area is a triangle. So it's the area of the triangle 1/2 k * x^2. Which the same result from the power law of calculus, integral of spring force f k * x, >> 1/2 k * x^2.
Kinetic energy KE = 1/2 m * v^2 (the book will say recall you know this from the last chapter).
Total energy TE is a constant, which makes your life easier. From the conservation of energy law, look at it and write TE = KE + PE (conservation of energy. Then knowing TE is a constant, TE = 1/2 m * v^2 (that's KE) - 1/2 k * x^2 (that's PE). The minus sign because KE = 0 at max PE or PE = 0 at max KE or PE = KE = TE when either KE or PE = 0. At least in that form you can look at it and recognize which is due to the spring and which is due to movement momentum.
Knowing the spring will oscillate if you pull on it and let it go, the proper form to write it is TE (a constant) = 1/2 m * v^2 cos(theta) + 1/2 k * x^2 i sin(theta), which is the model in the complex plane. That gets you to Euler TE (a constant) e^ i (theta) (a constant = 1) = KE + PE. They are a vector sum in the complex plane. There is a hidden sine wave which you do not have to deal with.
The i in the above is a vector rotation operator, by 90 deg, so the PE and KE are at right angles to each other and the sum is by the Pythagoras Theorem. The book gets that part wrong. The TE is the hypotenuse of the triangle.
The book does not teach it his way and is so horribly wrong. But everyone who flunks calc and needs a job is down at Jiffy Lube changing the oil on the teacher's car. So is a sense it does work for them.
The book will write the same problem as a "second order differential equation" then weep along with you about how hard it is to solve. Then to Jiffy Lube so you can make a living at it.