The alternator converts mechanical energy into electrical energy, by electro-magnetic induction.
In a simple version, a bar magnet rotates in an iron yoke which concentrates the magnetic field. A coil of wire is wound around the stem of the yoke. As the magnet turns, voltage is induced in the coil, producing a current flow. When the North pole is up, and South is down, voltage is induced in the coil, producing current flow in one direction.
As the magnet rotates, and the position of the poles reverses, the polarity of the voltage reverses too, and as a result, so does the direction of current flow.
Current that changes direction in this way is called alternating current, or AC. The change in direction occurs once for every complete revolution of the magnet.