Concept:
At the position of maximum elongation, the block momentarily comes to rest.
Hence, the loss of gravitational potential energy is completely converted into elastic potential energy stored in the spring.
Step 1: Apply conservation of mechanical energy.
Let the maximum elongation be \(x\).
Initially,
\[
K_i=0,
\qquad
U_{s,i}=0.
\]
At maximum elongation,
\[
K_f=0,
\qquad
U_{s,f}=\frac12 kx^2.
\]
The mass falls through a distance \(x\), therefore the loss in gravitational potential energy is
\[
Mgx.
\]
Hence,
\[
Mgx=\frac12 kx^2.
\]
Step 2: Solve for \(x\).
\[
x\left(\frac12 kx-Mg\right)=0.
\]
Ignoring the trivial solution \(x=0\),
\[
\frac12 kx=Mg.
\]
\[
x=\frac{2Mg}{k}.
\]
Step 3: Write the final answer.
\[
\boxed{x=\frac{2Mg}{k}}
\]
\[
\boxed{\text{Answer = (B)}}
\]