Snake charming is an ancient art, but is all trickery. The snake, often a cobra, is not “charmed” or affected in any way by the charmer’s music. The reptile can’t hear the sound of the music. It only sways its body sideways to follow the movement of the tip of the instrument exhibiting a defense reaction against something it perceives as threatening. Additionally, the snake charmers often remove the venom glands of the snakes and sometimes even the fangs to protect themselves. Some go as far as sewing the mouth of the snake shut, which ends up killing the reptile.
Shark charming is a different matter. The snout of sharks possesses a set of receptors called Ampullae of Lorenzini. They are named after the Italian physician and ichthyologist, Stefano Lorenzini, who first described them in the 17th century. Sharks use these receptors to detect small electric currents generated by their prey. If you rub the snouts of sharks you can activate these receptors and induce a trancelike state called “tonic immobility”. Scientists working with sharks use tonic immobility to perform several procedures with minimal struggle by the animal. However, some divers perform this for show or for paying customers, which has been criticized.