It's what is known as a tamper. A tamper re-aligns the track by lifting and slueing (moving laterally) using rollers that clamp under the rail head. Once the track is in the correct position, tools known as tines are forced either side of the sleeper that has been lifted. The tines then vibrate and squeeze, moving and consolidating ballast under the sleeper to keep it at that level. The tamper then moves along to the next sleeper(s) and repeats. A tamper can smooth out rough track, or put the design geometry into newly laid track.
There are different types of tamper, for plain line, switches and crossings, multiple sleeper lifting, continuous action (tool bank moves independently of the machine so the actual machine doesn't need to stop at each sleeper, just move along slowly) etc.