Hi tommio, great question! When we’re in a certain stage of sleep called Stage 4 (or Slow Wave) sleep, it’s still possible for use to move our muscles (as opposed to during REM sleep, when we’re paralysed). We still don’t fully understand why the brain tells our body to move when we’re asleep, but it can tell us to do all sorts of things – some people might sit up in bed, other people might talk in their sleep. Sleepwalking is just like these things, except it’s much more dramatic. Some researchers think that the reason it happens, especially in children, is due to a lack of a chemical in the brain called GABA (or to give it its full name, gamma-aminobutyric acid). GABA is involved in lots of stuff, but in this case, it’s involved in stopping motor neurones from transmitting movement signals to the rest of your body. If you have a lack of it, you’re more likely to move around in your sleep!
Sleepwalking also runs in families, which means that there’s probably a genetic component to it. Also, certain types of drugs can make it more likely, as can being stressed during the daytime.
Great questions! We don’t really know definitively the answer to this. However it is thought that at certain stages of sleep we are effectively paralysed, this stops us acting out our dreams and hurting ourselves. Some people are not able to paralyse themselves fully, and sleepwalking results.