Crabs walk sideways due to the structural component of the hinges that are present in their legs. Although crabs are capable of shuffling forward slowly, they are able to move a lot faster if they rely on moving by flexing the second joint of each leg, which only binds sideways.
Most crabs also have shells that are flattened and wider than they are long. As a result, crabs can easily burrow into the sand or hide in crevices. Their sideway walking motion is partially because of these shells, as the shells restrict the amount and range of movement that is possible for crabs at the hip joints, so that they are forced to rely on their knee joints.
King crabs are an exception to this rule. This is because king crabs have legs that can fold forwards and not only backwards, unlike other species of crabs. As a result, king crabs are perfectly capable of moving their legs and joints for a forward walking motion. The different physical characteristics found in king crabs may be attributed to the fact that they reside in deep sea environments where oxygen levels are minimal and water pressure is high. King crabs also typically travel longer distances than other types of crabs.