The outer shell of electrons of all the atoms in the metal are allowed to float between all the atoms - the negative electrons are attracted to more than one positive nucleii? in any one instant. This delocalised attraction? holds metals together, and also makes them malleable?.
The more electrons in the outer shell then the stronger the bonds with the metal. Hence Magnesium, which has 2 electrons in its outer shell, is stronger than sodium, with one electron.