Electrolytes are minerals — chiefly sodium, chloride and potassium — dissolved in body fluids. Sweat contains them, sodium in the largest amounts, so prolonged sweating removes both water and electrolytes. Electrolyte products (drinks, tablets, powders) are designed to replace those losses during and after exercise.
The American College of Sports Medicine position stand on exercise and fluid replacement reports that the goal of drinking during exercise is to prevent excessive dehydration (more than about 2% of body weight lost as water) and large electrolyte imbalances, and that sweat rates and sweat sodium content vary so widely between people that fluid plans should be individualised. It states that for exercise beyond roughly an hour, beverages containing electrolytes and carbohydrate can help sustain fluid balance and performance, and that including sodium helps retain ingested fluid and supports the drive to drink. The document also warns against overdrinking plain water in long events, which can produce exercise-associated hyponatraemia — dangerously low blood sodium. After exercise, it reports that normal meals and beverages with sufficient water restore balance, with rapid rehydration calling for about 1.5 L of fluid per kg of body weight lost.