During electrolysis of brine(aq. NaCl), NaCl and water are present as electrolyte.
Na+ (from NaCl) and H+(from water) tends to move to negative terminal (i.e cathode) while Cl- (from NaCl) and OH-(from water) tends to move to positive terminal(i.e anode).
Now only one from Na+ and H+ at cathode will get reduce which has higher standard reduction potential.
Standard reduction potential of Na+ (E°=-2.71V) which is quite less from that of H+ ion (E°=0.00V), H+ reduces at cathode and H2 gas will produce. Similarly only one from Cl-and OH- will get oxidise at anode, which has lower standard reduction potential. Standard reduction potential of Cl-is. E°=1.36V while that of H2O/OH- is 1.23 V. So Standard reduction potential of hydroxide ion is less than that of Cl- ion , which implies that O2 must be released by oxidation of hydroxide ion.
But reality is different due to over potential of H2O /OH- doesn't get oxidise easily and requires high potential then calculated value, so at the given potential Cl- gets oxidise at anode and Cl2 gas is liberated . So Cl2 gas is liberated at anode and H2 gas is at cathode.
The rest Na+ and OH- are in the solution and forms aq NaOH.