A commutator in a DC Machine has alternate bands of Copper and mica. Now when the armature starts to rotate by an external force (in DC Generator), the coils situated in the armature also rotate. The coils are shorted via brush segment with alternate change in influence of poles. This alternate change via the commutator produces unidirectional current flow.
What a commutator does is change the conductor after a half cycle so a single terminal always experiences same EMF. Figure below shows difference between DC and AC commutator system.
While AC commutator system produces an alternating current, DC system would produce a Rectified (full wave) alternating current. Increase the number of conductor coils in the armature and you have a series of full wave rectified EMF with slight phase difference spanning the entire 180 degrees. So it’s almost like a DC rectifier.