Consider two-spring mass system below.
|--/////--|M|---////--|
Let the left spring be spring 1 with elasticity coefficient $k_1$ and unstretched length $l_1$. Also, the right spring is spring 2 with elasticity coefficient $k_2$ and unstretched length $l_2$. The |M| stands for mass $m$ and the "|--" and "--|" is the wall that system is attached to. I was asked to come up with a model for this.
Here's what I think. Let $p$ be the distance from wall to wall. Let's apply force to the positive $x$-direction, so mass $m$ moves to positive $x$-direction. Also, let $x$ be the distance from left wall to the mass. When mass $m$ moves the positive $x$-direction, we have spring force of spring 1 to the negative $x$-direction. Spring 1 stretched by $x-l_1$. So the spring force is $-k_1(x-l_1)$. Also, when mass $m$ moves to positive $x$-direction, we have another spring force. Spring 2 is compressed by $(l_2-(p-x))$, so the force is $-k_2(l_2-(p-x))$ since the force is to the negative $x$ direction.
Using newton's law, we have $F=ma$, so the model for the system is $$-k_1(x-l_1)-k_2(l_2-(p-x)) = m \frac{d^2 x}{dt^2}$$
Is this model right? Also, in the book, I was given that the distance from wall to wall is $p$. I was asked to explain why it is not necessary for $p=l_1 + l_2$. I am not sure why it is not.
Your equation should have subscripts on the $k$s because in the problem the spring constants can be different. The $l_2-x$ term is not correct because you are measuring $x$ from the left wall. The force is proportional to the difference between $l_2$ and the distance from the mass to the right wall. That distance is $p-x$ so your $l_2-x$ should be $l_2-(p-x)$. You don't need the sum of the distances between the walls to be $l_1+l_2$. If it is different, at equilibrium the two springs will each be stretched in such a way that they apply equal and opposite forces to the mass. The mass will then oscillate around the equilibrium position. It simplifies things a bit if you measure $x$ from equilibrium, instead of from the left spring equilibrium.