Most of the liquids that usually come in contact with electronic devices are water based, so let us stick with water. The water that we use is never pure water, it contains dissolved electrolytes, such as sodium chloride (table salt). Pure water is a very poor conductor of electricity, but when it contains ions (sodium and chloride), it can act as a good conductor of electricity.
So, if this ion-filled water comes into contact with any electronic device in ON state, it is going to make connections in places, where there should be no connection resulting in large current which in turn damages the circuit. So, if you have had a spill on your device in its OFF state, it is very possible that it will start working as long as you dry it up sufficiently before turning it on as the dried water can no longer make any undesired connections.
There is a second reason: Corrosion. Corrosion happens on long term exposure with water. The connections between different devices is done using metal. When metal comes into contact with water, it starts corroding and converting to another non-conducting compound. Since the water contains a lot of ions, it speeds up the process of this corrosion. You can see in places with salty water (including coastal regions), things corrode very fast. Once the metal connection between two parts of the circuit is sufficiently corroded, the connection is broken and electronic device stops working.
Short term exposure to water while device is ON causes short circuit which results in high current causing burning of the device.
Long term exposure to water while device is either ON or OFF causes corrosion which breaks the connection between two parts of the circuit causing malfunction of the device.