It's not clear to me what "block-earth" system is supposed to mean, either, particularly when there are two blocks. The key word in the problem is that they say it's an elastic collision. Therefore, the total momentum and energy of the two blocks are conserved quantities. That's all one really needs to know in order to solve the problem.
Edit: a full analysis of the problem. Prior to collision, block 1 has $E = m_1 gh$ and block 2 has no energy. Just prior to collision, all this energy is kinetic, so $p^2/2m_1 = m_1 gh \implies p = m_1\sqrt{2gh}$.
After the collision, total momentum and energy must be conserved.
$$\begin{align*} p_1 + p_2 &= p \\
\frac{(p_1)^2}{2m_1} + \frac{(p_2)^2}{2m_2} &= E\end{align*}$$
A straightforward way to attack this system of equations is to solve the first by $p_2 = p-p_1$ and substitute into the second, yielding
$$m_2 (p_1)^2 + m_1 (p^2 - 2pp_1 +[p_1]^2) = 2 m_1^2 m_2 gh$$
Solve this for $p_1$, the momentum of block 1 after the collision, using the usual methods for solving quadratic equations. Once you have the momentum, you should be able to find the final height as the block goes back up the ramp.
I shall assume that the spring is to the right of the block and therefore does not get hit, and will take the positive direction to be to the right.
The surface is smooth and the spring is ideal so there are no dissipative forces, so all energy involved will be either in kinetic energy or the potential energy of the spring.
To calculate the velocity of the block, mass $M$ say, we use conservation of momentum in the collision with the stone, mass $m$ - the stone comes in at velocity $u_i$ (which is to the right) and leaves with a velocity $u_f$ (which happens to be to the left, but this will only be important when we put the numbers in and will be negative). We'll call the velocity of the block after the collision $v$ (it was at rest before). So total momentum before = total momentum afterwards gives:
$$mu_i = mu_f + Mv$$
so that
$$v = {m(u_i-u_f)\over M} = {3(8-(-2))\over 15} = 2m/s.$$
Notice that I have used a negative value for $u_f$ because we are told that the stone leaves to the left, i.e. the negative direction, and that $v$ ends up being positive, i.e. the block moves to the right, the positive direction.
After this collision we are done with the stone, and concentrate on the block and the spring. When the block first comes to rest it will be because all of its kinetic energy has been used to compress the spring, giving the spring potential energy. The distance it moves will correspond to the extension $x$ (or compression if you like) of the spring when it has this value of the potential energy. So KE of the block = PE of the spring gives:
$${1\over 2}Mv^2 = {1\over 2}kx^2$$
so that
$$x^2 = {Mv^2\over k} = {M{\left(m(u_i-u_f)\over M\right)}^2\over k} = {m^2(u_i-u_f)^2\over Mk} = {3^2(8-(-2))^2\over15\times525} = {900\over7875}$$
and so
$$x=\sqrt{{900\over7875}} \simeq 0.338m.$$
In the last block of algebra I could have just put in $v=2$ rather than putting the full expression in terms of the given variables, but it would have come out exactly the same, and we can see a little more of the dependence this way.
Best Answer
When to use which law
Your assumption that conservation of energy (considering only kinetic energy) works while dealing with the collision in the above question is not correct.
Conservation of energy (kinetic energy) doesn't appear to work in all kinds of collision. Some of the initial kinetic energy of the bodies are lost as heat and/or part of it is stored in the form of potential energy of the bodies (deformed body). These kind of collisions are called inelastic collisions.
Hence, direct application of conservation of energy with just kinetic energy terms is not possible. In these cases, the problem cannot be solved with just conservation of momentum. You need some experimental input (usually the coefficient of restitution is given).
However, there are cases where conservation of energy (initial kinetic energy = final kinetic energy) is applicable. Such collisions are called elastic collisions.
Conservation of momentum is always valid and safe whereas conservation of energy requires all forms of energy including heat, sound, light, etc to be considered (which ever stated)
Solution to the given problem
In the above problem, the final velocity of the block is already given. By using the conservation of momentum, you can calculate the final velocity of the block.
Initial Momentum of the stone= $mv$ = $24$ $kg.ms^{-2}$
Applying the law of conservation of momentum,
$24 = m_{stone}v_{final-stone} + m_{block}v_{block-final}$
Substituting the given values in the equation, you get the final velocity of the block to be $2 ms^{-2}$.
Before the collision, the block was at its mean position. After the collision the block will begin to oscillate with the same mean position.
The total energy of the system is equal to the kinetic energy supplied by the moving stone. When the block reaches its extreme position, all the energy will exist in the form of potential energy of the spring. Therefore, by applying the law of conservation of energy,
$\frac{mv^2}{2} = \frac{kx^2}{2}$
You get x to be $\sqrt{\frac{3}{20}}$