To you it might look silly, but the reason a crab walks sideways is because that’s how it can move the fastest, due to the way its legs are built!
Take a look at a picture of a crab. You can probably see that its legs have two joints – one up near the crab’s body and another in the center of its leg. The joint that is up near the crab’s body can allow the crab to move forward but is restricted in a way that only allows a crab to move slowly in this direction.
To move more quickly, crabs can use the other set of joints in their legs, which work a lot like our knees. It’s because of the placement of these joints and their range of motion that crabs end up walking sideways. – It’s just like how the placement of your knees can only bend forward… a crab’s can only bend sideways!