I have a 4yo. My first course of action would be to ask her about it to see if she can answer your question without you having to be a detective. If you awaken her to move her back to bed, ask her then. Ask her in the morning if she remembers and ask her why she does it. If she doesn’t remember, leave it at that, don’t bother her with it again - you don’t want to upset her by making her think she’s doing strange stuff when she goes to sleep.
Maybe your child “has a job to do” and is sleepwalking because of it. Let me explain:
My dd was sleepwalking about a year ago. We had just taken the safety gate off of her bed, and she had fallen out a few times. Not enough for us to think the gate HAD to go back on. But I was reading Dr. Ferber’s book “Solve Your Child’s Sleep Problems” at that time (for other reasons), and took note of one of his points. He suggested that sometimes when a child is afraid she is going to wet the bed, or fall out of bed, she goes to sleep knowing that she has to be careful not to let that happen. In the child’s mind, she “has a job to do” and she doesn’t let herself just fall into a completely relaxed state. This actually can affect her ability to move through the stages of sleep smoothly and the result can be a sleep disturbance like sleep walking. In my daughter’s case, her “job” was to keep from falling out of bed. It apparently stressed her out enough that she sleepwalked. One night, we put the safety gate back on her bed, and she never sleepwalked again.
See if there is some change that has happened in her life that is giving her a “job to do” when she goes to sleep. Did you remove the safety gate? DId you move her to a different room? Did she just stop wearing pullups at night? Did something happen to make her feel like she has to watch out for her safety when she goes to bed? If she does “have a job to do” then you just have to figure out how to remove that job from her responsibility.