Piezoelectric materials work by converting mechanical energy into electrical energy and vice versa. When these materials are subjected to mechanical stress, they generate an electric charge. This principle is utilized in various medical devices, such as ultrasound equipment, where mechanical vibrations are converted into electrical signals to create images of the body's internal structures.