In the aqueous state, the slightly negatively charged oxygen atoms of the polar water molecule exerts a pull on the positively charged sodium ions. A similar pull is exerted by the slightly charged hydrogen atoms of the water on the negatively charged chloride ions. Thus the ions become free in solution. These free ions conduct electricity.
In the molten state, the high temperatures required to melt the solid weakens the bond between the particles and the ions are set free.