This is true for some sharks, but not for all sharks.
Basically, sharks move water across their gills by swimming. Water flows in through their mouths, across their gills, and out through their gill slits. This is in contrast to bony fish that can gulp in water and pump it across their gills without having to move.
Some species of shark also have the ability to pump water across their gills while at rest, but others lack this ability. In the latter case, these sharks must continuously swim to breathe. Stopping would mean death due to a lack of oxygen.
A second reason that sharks must generally keep swimming, though, is that they do not have gas bladders to help them stay afloat. Bony fish can make themselves more or less buoyant by inflating or deflating their gas bladders. Sharks, on the other hand, must stay afloat in much the same way an airplane does in the air. Water flowing across their fins while swimming provides them with lift, allowing them to rise or fall in the water. If they stop swimming, this flow of water stops, and they start to sink. This could, in certain circumstances, also be deadly.