The figure above helps you understand how an alternator or AC generator works. According to Faraday's law of electromagnetic induction, when a conductor moves in a magnetic field EMF is induced through the conductor. If the closed path is given to the conductor, the induced emf causes the current to flow in the circuit.
Now, see the previous figure. Let the conductive coil ABCD be placed in a magnetic field. The direction of the magnetic flux will be the pole N to the pole S. The coil is connected to sliding rings, and the load is connected through brushes resting on the sliding rings.
Now, consider case 1 of the previous figure. The coil is rotating clockwise, in this case the direction of the induced current can be given by the rule of the right hand of Fleming, and will be along A-B-C-D.
When the coil rotates clockwise after half the time period, the position of the coil will be in the second case of the previous figure. In this case, the direction of the current induced by the rule of the right hand of Fleming will be along D-C-B-A. It shows that the direction of the current changes after half the time period, which means that we receive an alternating current.
It can be understood in the following video: