I have come to known that both longitudinal and shear strain act on a spring when it is hanging. I can understand how longitudinal strain acts but I do not understand why shear stress/strain can act on the spring.
The shear strain is due to the wire of the spring being under torsion (twist). The torsion arises because the force, F, due to the mass hanging from the spring acts along the (vertical) axis of the spring, which runs through the centres of the turns (or radius r, say). This force therefore exerts a torque $Fr$ on the wire of the spring. The torque is countered by the torque due to the twisting of the wire.