If we use the formalism of statistical mechanics we can calculate the [canonical] partition function of a gas, as a function of volume $V$ and temperature $T$:
$$Z(T,V) = \frac{1}{h^3}\int_V\int_{\mathbb{R}^3} e^{-\frac{H(\boldsymbol{x},\boldsymbol{p})}{kT}}\text{d}^3\boldsymbol{p}\text{d}^3\boldsymbol{x}$$
where $H(\boldsymbol{x},\boldsymbol{p})$ is the hamiltonian for a single molecule. The Helmholtz free energy is given by:
$$F(T,V) = -kT \ln \frac{Z^N(T,V)}{N!}$$
being $N$ the number of molecules. The pressure can be computed as the derivative:
$$p = -\left( \frac{\partial F}{\partial V}\right)_T$$
For an ideal gas we have:
$$Z = \frac{V(2\pi mkT)^{3/2}}{h^3}$$
and, consequently:
$$F = -kNT \left( \ln V + \frac{3}{2} \ln T + 3\ln \frac{\ln\sqrt{2\pi mk}}{h} \right), \qquad p = \frac{NkT}{V}$$
For a non-ideal gas, the partition function is more complicated but esentially we have:
$$Z = \frac{f(V,T)(2\pi mkT)^{3/2}}{h^3}$$
which lead to:
$$p = \frac{NkT}{V} + \frac{N^2A(T)}{V^2} + \frac{N^3B(T)}{V^3} + \dots $$
The reason: the mass $m$ mass appears factored apart from the volume in the Helmholtz free energ $F$, so the derivative $p = -\partial F/\partial V$ in independent of $m$.