I experienced a weird situation a while back wherein I was dreaming hut was pretty sure I was in a dream and could control it to my wishes. I even had a break in my sleep and immediately went back to sleep and was again in the same situation. Can someone try to go in this state by planning or is it purely random?
The term for this phenomenon is "lucid dreaming". It is common to have some lucid dreaming experiences, but different people have different occurrence rates of lucid vs non-lucid dreams, and the level of "control" varies as well.
A previous SE Q&A addresses some of the possible influences on lucid dreaming including the potential to learn to have more lucid dreams as a skill.