An aqueous solution contains the ions of the dissolved compound and also a few ions from the water itself: hydrogen ions, H+, and hydroxide ions, OH-. So at each electrode two ions compete to be discharged.
At the cathode, a metal forms only if it is less reactive than hydrogen, for example copper or silver. If the metal is more reactive than hydrogen, such as sodium, hydrogen gas forms instead. At the anode, a halide ion (chloride, bromide or iodide) forms its halogen. If there is no halide ion, as in a sulfate solution, hydroxide ions are discharged and oxygen forms.
Aqueous sodium chloride gives hydrogen at the cathode and chlorine at the anode. The solution left behind contains sodium hydroxide. Aqueous copper sulfate with inert electrodes gives copper at the cathode and oxygen at the anode, and the blue colour fades as copper ions are used up. In the practical, hydrogen gives a squeaky pop with a lit splint, chlorine bleaches damp litmus paper and oxygen relights a glowing splint.