No reason to think that the work done by the spring force will equal the work done by gravity. Note that it doesn't say that 4 in is the maximum compression of the spring... the block keeps going!
Instead, consider conservation of energy (assume no energy is lost when the falling block hits the "massless" spring). What's the initial energy of the block just as its being dropped? What's the final energy of the block + spring system when the spring has been depressed 4 in?