This is because there is very less friction between the wheels of the locomotive and the train.
This is the fundamental principle based on which railways were developed. Steel wheels on steel rails experience far lesser friction than say, rubber wheels on a road (like trucks and cars). In fact the friction reduces by almost 85-95%, which makes it extremely easy to pull or push very heavy loads on rail tracks.
As an example, using very simple approximations and numbers, one can illustrate how easy it is to move things on rails.
On...
more... straight, level tracks, the amount of force required to push a 1 ton (1000kg) wagon, is the same as the amount required to lift about 2.5kg. So, pushing a WAP4 loco, weighing about 110 tons only requires the same effort as required to lift a 250kg weight. This is something that 4 or 5 reasonably strong people can manage easily. The loco will move very, very slowly, but it is possible to just push it.
Obviously this is a simplified calculation, and the numbers change based on many parameters, but the point is to illustrate that it is very easy to move coaches and wagons on railway tracks.