During electrolysis, the electrolytes ionize into their respective positive ions (cation) and negative ions (Anions) and also the water releases OH– and H+ for an aqueous solution.
Then all the positive ions are attracted to the cathode while the negative ions are attracted to the anode.
The ions to be discharged at the anode and cathode depend on some factors.