In general, and this is somehow speculative, the animals that you mention have more autonomy in their extremities and less control from a head, muscles have evolved autonomous responses perhaps as an evolutionary advantage, ( i.e. having a brain be in charge of reactions can add precious milliseconds ), there also seems to be a relationship in between brain size ( specific motor control areas) and this autonomy, which introduces a metabolic cost (i.e. our big heads need a lot of energy) Further, there are other biological considerations for providing extremities with their own resources and thus to a degree be more independent, perhaps another evolutionary strategy. At the other end of this control-autonomy relationship, the head takes control of the extremities most of the time and their interdependance is greater, so if you cut it no movement will happen, although we still possess a few hard coded reflexes that work for a while provided they have enough energy left or a blood source.
To give you an example: a cat ( somewhere in the middle ) can still walk when you cut the connections from the brain /head to the legs due to reflex actions ( the cat has to be on a treadmill though).