In electrolysis a direct current passes through an electrolyte. Inert electrodes, such as graphite or platinum, conduct electricity but do not react, so any products come from the electrolyte itself.
A solution contains the ions of the dissolved compound and also H+ and OH- ions from the water. In copper chloride solution the Cu2+ ions move to the cathode, gain electrons and form a pink-brown coating of copper. The Cl- ions move to the anode, lose electrons and form bubbles of chlorine gas, which bleaches damp litmus paper.
In sodium chloride solution the ions present are Na+, Cl-, H+ and OH-. At the cathode, hydrogen forms instead of sodium, because sodium is more reactive than hydrogen, so the sodium ions stay in solution. Hydrogen gives a squeaky pop with a lit splint. Chlorine forms at the anode. The solution left behind contains Na+ and OH- ions, so it is sodium hydroxide solution, which is alkaline.