Firstly, it's important to recognise that ionic compounds and metals are two different structures. Ionic compounds consist of positively charged ions and negatively charged ions held together by strong electrostatic forces of attraction.
Solid metals are made of layers of positively charged ions with electrostatic forces of attraction with a sea of delocalised electrons.
To conduct electricity, charged particles must be free to move around. In a metal, the delocalised electrons are always free to move around, so a solid metal can always conduct electricity.
When an ionic compound is solid, the oppositely charged ions are fixed into place. Because they're fixed into place, they aren't free to move around to carry a charge, and therefore cannot conduct electricity.
When ionic compounds are dissolved in water, the ions aren't held together by strong electrostatic forces of attraction anymore. They can therefore move around freely, and conduct electricity.