Cats do the crab walk to ensure that the side of their body always faces the hostile stranger opposite who may be a threat to them. The crab walk makes cats look as large as possible. Size counts as it does in the human world. Their size is further enlarged by the hairs down their spine becoming erect. It is all about smoke and mirrors to try and see off the unwanted intruder. It is better to scare them off than fight them as it avoids injury.
We often see kittens practicing the crab walk with great elan and joy. They almost bounce along when travelling sideways. When my cat was a kitten he would see his shadow on the wall from my bedside light (he was on my bed with me). He immediately treated his shadow as a hostile cat and started to do the crab walk with gusto. This meant that his shadow bounced around more which made it more interesting for him.
The crab walk is one of many forms of domestic cat behaior and body language when facing a “hostile”. Sometimes cats add a weird growl or more likely a hiss to their crab walk to further try and scare off the opposing cat. And as you know the ears are flattened to protect them and the tail is fluffed to add to the sense of size.