They can do this because the nerve and muscle systems in the human body are electrical. For example, an amputee with a myoelectric arm tenses his or her remaining arm muscle. Signals also can go from the environment to the patient, allowing an approximation of the sense of touch. For example, some prosthetic hands have sensors that can detect heat or cold and transmit that information to electrodes on the patient's skin. Researchers are still improving prostheses.
New materials allow artificial feet to press and spring on the ground very much like a real foot.
One type of artificial foot transmits electronic information about pressure to amputees, allowing them to balance because they can tell whether their weight is on the toes, heels, or sides of the feet. Connections Artificial limbs are very expensive. Make a list of some of the movies you have seen recently. They look and work more like the real thing. Builder of hopes.