The definition for electrophoresis given by Lehninger et al. (1993) is "Movement of charged solutes in response to an electrical field; often used to separate mixtures of ions, proteins, or nucleic acids". It is the separation of the latter (specifically DNA) that applies to agarose gel electrophoresis (separation of RNA or proteins is generally done using other types of gels like polyacrylamide).
Electrophoresis is a powerful technique for separating molecules based on their charge distribution and size. Over the years a number of variations on the technique have developed, but in general terms, a gel matrix is used as a medium for separation and placed into a chamber containing buffer (usually TAE or TBE), with an anode at one end and a cathode at the other end. A charge is applied through the chamber and molecules of different sizes and charge ratios migrate at different rates through the gel, toward the oppositely charged end.
In the case of DNA, which has a negative charge, migration is through agarose gels toward the anode. The pores of the gel slow the longer strands down so separation also based on size.
Lehninger et al. 1993. Principles of Biochemistry, Second Edition. Worth Publishers, New York, NY.