How do ionic and molecular compounds dissolve?
Both dissolve in a similar way, but are different in the detail. They dissolve because they are able to form more stable bonds or associations with the solvent molecules than they have holding the solid together.
If we consider ionic solids first, then what is holding them together is the electrostatic attraction between the ions. When they dissolve, the ions form bonds with the solvent molecules, and the energy released when this occurs is more than the energy needed to overcome the electrostatic attractions in the ionic lattice. I have omitted talking about entropy here which also has a role - depends how much depth you want to go into...
For molecular solids, the force we must overcome is the intemolecular forces between the molecules. When dissolved, there will be intermolecular forces between the molecules of solute and the molecules of solvent. If these are stronger than those between the solute molecules when it is solid, dissolving will take place. Again entropy has a role to play and I have neglected it for simplicity.