Your question implies that crabs are more versatile breathers than they really are. Crabs can be divided into three broad categories: aquatic (mostly marine), intertidal, and terrestrial. Each type is able to live only in its own environment. Aquatic crabs have gills and breathe underwater like fish. Take them out of the water for too long and they will suffocate because their gills collapse. Some intertidal crabs are able to breathe both in water (by means of gills) and out of water (using thin areas of cuticle on the leg bases) but they have to stay moist for the cuticle to function. Terrestrial crabs have stiff gills that function well out of water but not in it; if you put them into water with no way out, they'll drown eventually. Some terrestrial crabs, especially those that live in really dry habitats, also have lungs.