During electrolysis, positively charged ions move to the cathode and gain electrons. Gaining electrons is called reduction, so the reactions at the cathode are reductions. Negatively charged ions move to the anode and lose electrons. Losing electrons is called oxidation, so the reactions at the anode are oxidations.
These reactions are written as half equations, which show the electrons. At the cathode the electrons are on the left-hand side, as they are gained, for example 2H+ + 2e- → H2 and Pb2+ + 2e- → Pb. At the anode the electrons are on the right-hand side, as they are lost, for example 2Cl- → Cl2 + 2e- and 2Br- → Br2 + 2e-.
A half equation must balance for both atoms and charge. Hydroxide ions give oxygen: 4OH- → O2 + 2H2O + 4e-. It can also be written 4OH- − 4e- → O2 + 2H2O. Check: on the left, 4 negative charges; on the right, 4 electrons carrying 4 negative charges.