It’s complicated! Your muscles are connected to the bones by tendons, so when your muscle pulls, it pulls the tendon which moves the bone. Nature has cleverly evolved our bodies so that when the muscle pulls, it pulls the bone around joints. So to move your foot up, your shin muscle pulls, and to move it down, your calf muscle pulls, and this pivots your foot around the ankle. Same idea with the other joints, but different muscles. Your brain sends tiny electrical pulses through nerves to the muscles telling which ones to pull, and how much. I find this amazing, and really don’t understand it! Maybe one of the other scientists knows more about this than me?