It comes from the fact that you must take a central extension of the classical Galilei group to the quantum Galilei group with the mass ##m>0## of the particle as a central charge, because it turns out that the unitary representations of the classical Galilei group do not lead to any sensible quantum dynamics. Thus the commutation relation with the non-trivial central charge, the mass of the particle, reads
$$[\hat{K}_j,\hat{P}_k]=\mathrm{i} m \delta_{jk} \mathbb{1},$$
and one also has the commutator
$$[\hat{K}_j,\hat{H}]=\mathrm{i} \hat{P}_k.$$
Further, since Galilei boost must be a symmetry of the theory according to Noether's theorem one must have
$$\frac{1}{\mathrm{i}} [\hat{K}_j,\hat{H}]+\frac{\partial \hat{K}}{\partial t}=0.$$
With the commutation relation this implies that ##\hat{K}## must be explicitly time dependent and
$$\frac{\partial \hat{K}_j}{\partial t}=-\hat{P}_j.$$
Since further the Galilei algebra shows that ##[\hat{P}_j,\hat{H}]=0## and since also ##\hat{P}_j## is conserved, because translations must be a symmetry too, ##\hat{P}_j## is not explicitly time dependent, and thus the equation solves to
$$\hat{K}_j=m \hat{X}_j-\hat{P}_j t,$$
where ##\hat{X}_j## is not explicitly time dependent. Now again the (quantum!) Galilei algebra tells us that the ##\hat{P}_j## commute among each other but that
$$[\hat{K}_j,\hat{P}_k]=m [\hat{X}_j,P_k]=\mathrm{i} m \delta_{jk} \mathbb{1}.$$
This shows that with ##m \neq 0## you get the usual Heisenberg algebra, and we have been able to construct the usual position operator for non-relativistic massive particles. As stressed above, for ##m=0## we don't get a sensible quantum dynamics at all, as was shown by Enönü and Wigner in
E. Inönü and E. P. Wigner. Representations of the Galilei group. Il Nuovo Cimento, 9(8):705–718, 1952.
The relativistic case (i.e., the Poincare group) is different, because it does not have any nontrival central charges, i.e., all unitary ray representations are equivalent to unitary representations, and the quantum Poincare group is the same as the classical. Furthermore there are causal local QFTs and thus physically well interpretible models for both massive and massless particles. Mass is not a central charge but a Casimir operator of the Poincare group and thus one of the parameters determining the irreducible representations of it and thus the properties of elementary particles, which are by definition those objects which are describable as irreducible representations of the Poincare group.