Why can we approximate arbitrary volumes $V$ with cubic boxes of volume $L^3=V$ in quantum mechanics? I've been studying quantum mechanics for two years now and it seems that in every textbook authors like to work with a box of size $L^3$ rather than an arbitrary volume $V$. Now the reason why seems obvious to me: it facilitates the calculations. But my question is: why are we allowed to do it? For example, one always quantize a free particle momentum by $\vec{p}=\frac{h\vec{n}}{L}$ so implicitely assuming it it is in a box of length $L$.
In particular, I was asked to find the density of states of an ideal Fermi gas of $N$ fermions in a volume $V$. If we are allowed to approximate $V$ by a box of size $L^3$, then I am able to solve that question but am I allowed to do that approximation?
 A: Explicitly computing the density of states for an otherwise free particle confined to an arbitrary volume $V$ is not possible, simply because the spectrum of the Hamiltonian cannot be determined without more information about $V$.  For example, if $V$ is a rectilinear box the allowed energies would be different than if $V$ were a sphere.
However, this is not necessarily a problem in applications.  Often times we assume that the particle is confined in some volume $V$ and then take the limit as $V\rightarrow \infty$, in which case the spectrum of the Hamiltonian will approach that of the free particle Hamiltonian on $\mathbb R^3$.  This is what is done in your exercise - note that otherwise the density of states would be a sequence of delta functions, since the allowed energies would form a discrete set.  Only in the limit as $V\rightarrow \infty$ do they form a continuum, making the concept of a continuous density of states (and continuous allowed energies) reasonable.  As an exercise, you can compute the density of states for a particle confined for a spherical region and then let $R\rightarrow \infty$; check that you get the same result as you'd get if you assumed the region to be a box.
Other times, we simply use the idea of a particle confined to some volume as a toy model of a real scenario.  It has the qualitative features we're looking for, but the numbers are quantitatively not quite right (nor are they meant to be).
The extent to which the geometry of the confining region is important really depends on what you're trying to do.  To be sure, there are many problems in which this geometry really matters, but calculating e.g. the spectrum of the Hamiltonian for particles confined in a complicated volume can generally only be done numerically.
A: We can put the system in a box with sides of length $L$ when at the end of the calculation we plan on taking the thermodynamic limit and we are not interested in any physics at the surface of our system. That is, we take $N\to \infty$ and $L\to \infty$ while keeping $N/L^3=$ const. After taking this limit, the particular shape of the volume we started with should not matter. So we choose the most convenient: a box.
The factors of $L^3$ which we carry around before taking the limit can disappear in a few ways. For example, as you point out, our momentum states are quantized and so when we calculate average properties, we often end up having sums which look like
$$ \frac{1}{L^3}\sum_k \dots $$
But when we take the thermodynamic limit, the $k$-states becomes arbitrarily close to each other in momentum space and the volume is absorbed into an integral:
$$ \frac{1}{L^3}\sum_k \:\mapsto \:\int \frac{d^3k}{(2\pi)^3}$$
Alternatively, we might just find $L^3$ appearing as $N/L^3=n$ and so we just have a finite factor of the density in our end result.
