Most bacteria with polar flagella, like the peritrichous above, can rotate their flagella both clockwise and counterclockwise. If the flagellum is rotating counterclockwise, it pushes the bacterium forward. When it rotates clockwise, it pulls the bacterium backward. These bacteria change direction by changing the rotation of their flagella.
Some bacteria with polar flagella can only rotate their flagellum clockwise. In this case, clockwise rotation pushes the bacterium forward. Everytime the bacterium stops, brownian motion and fluid currents cause the bacterium to reorient in a new direction.