Please read up on "motor learning" (better known as "muscle memory"). It's nothing to do with muscles having memory, but with intensive training through repetition that results in permanent (or near-permanent) change in the physiology of the motor cortex (spinal motor circuit control), basal ganglia (action selection) and cerebellum (fine action control). The prefrontal cortex - the part of the brain "that thinks" (specifically the planning, decision-making and personality part) - isn't involved in muscle memory.
Walking is a terrific example. We aren't born knowing how to walk, but we learn how to do it and can eventually manage to accomplish it - standing up is quite a balancing act and walking really is just a series of controlled falls - without having to put any effort into thinking about it. By repetition you effect a permanent change in the basal ganglia (which selects actions for you without conscious control), cerebellum (which governs the precision of those actions) and motor cortex (which drives the muscles). Ever heard the phrase "It's like riding a bike - you never forget how"? That's muscle memory.