Because, they systems spring-mass-damper is the order 2, therefor you need two state variable, position and velocity, and well, these magnitudes represent flows and are analogous to electric charge and current.
Conservation of energy - the energy of the system can be modelled as (1/2)kX2 (for a linear spring) plus kinetic energy (1/2)M(dx/dt)2 involving both distance and velocity/ The sum of the two is constant and in phase space (distance v. velocity) describes an eclipse - both variables are needed to define the point on this eclipse.
Everything that has been said is correct. I would like to clarify a few details.
the mass-spring system is a dynamic system governed by a differential equation of order n = 2 with position and velocity as variable. when transcribing this system to the state space representation (according to the phase plane) there must be a match between the state space dimension and the order of the DE. therefore we will have a state vector of dimension n = 2.
A few more details: Since it is second order it must be replaced by two variables y_1dot = f1 and y_2 dot =f2 to get a state of second order. There are various ways of picking y_1 and y_2 as combinations of x and xdot but the easiest way by far is to pick y_1=x nd y_2=xdot.
State-space variables are mandatory to fully describe (know) a system status at any specific time. If the information related to any of the state variables is missing at any time t, then it would be impossible to determine (know) the system status at that time t. For example, for the dynamic system under consideration, to describe the system status at any time t, we need to know both the velocity and the position of the particle at that time. If we only know the position (only one state variable), then it is not possible to determine in which direction the particle is moving and at what speed at that time. Again, if we only know the velocity of the particle at t (one state variable), then it would be again impossible to find out the current position of the particle. So, by knowing the values of both velocity and position, we would be able to fully describe the system status.
Another way to explain this, 'Any n-th order ODE can be decomposed into n number of 1st order ODEs'. Hence, as the original differential equation is of order 2, there are actually two ODEs defined by two state variables.
It comes from the differential equations of motion which for linear equations can expressed using Laplace Transforms as linear vector / matrix simultaneous equations that can solved by Cramer's rule or numerically. In the Laplace domain the system can studied in terms of bandwidth, stability, high Q frequency.