Water holds heat longer than soil because water has a higher heat capacity than soil. Water's high heat capacity results from the large amount of heat energy required to break the hydrogen bonds in individual water molecules.
The broken hydrogen bonds allow additional heat energy from a heat source to excite the water molecule, causing it to vibrate and bump into surrounding water molecules. This vibrating action allows the excited water molecule to impart some of the heat energy it gained from the heat source. Only when enough heat energy has been imparted to the surrounding molecules to break their hydrogen bonds do those surrounding molecules heat up.
This does not occur in soil, which is a poor insulator of heat energy because of its low heat capacity relative to water. This means that soil quickly transfers heat energy, allowing it to heat up and cool down quickly.