Hydrogen reduction is kinetically so slow on mercury, that once we supply enough voltage sodium is reduced faster.
Electrochemists describe how slow an electrochemical reaction is by the term overpotential (https://en.wikipedia.org/wiki/Overpotential).
Overpotential is the amount of extra electrode potential -- more negative for a reduction, or more positive for an oxidation -- beyond equilibrium, which we need to make the reaction go at a certain rate. For example the equilibrium potential for hydrogen reduction from acid might be 0.00 V, but if we need an extra 0.50 V to get the reaction to go at the rate we want the real electrode potential would be -0.50 V. Note that this would be enough to reduce nickel, if the overpotential for that reaction is small enough, even though nickel "should be" harder to reduce than hydrogen.
In the case of hydrogen reduction on mercury, the kinetics is so slow that you need a huge amount of overpotential to get it to go at a reasonable rate. That overpotential is enough to make sodium reduction possible too, and the sodium reduction is kinetically faster.
If you use a platinum electrode instead, that does not happen. Quite the opposite, the kinetics of electrochemical hydrogen reduction is fast on platinum. So there is little overpotential, and thus platinum is used for the "standard hydrogen electrode" against which the electrode potential of other reactions are measured.