Surface Tension.
In the absence of any other force, surface tension will cause a liquid to form a volume with the smallest surface area (a sphere)
Gravity also acts and causes the sphere to flatten.
Exactly the same thing happens to water on a non-wetting surface (eg waxed paper) and globules of fat floating in your warm gravy.
The reason it doesn't usually happen with water is because water wets most surfaces and the force of adhesion with the surface is greater than the force excerted by surface tension. Mercury does not wet the surface, so surface tension is the strongest force acting there.