The traditional approach to solving the particle in the box is origin-specific and results in inconsistencies in calculation of the energy $E$ (see Lack of Invariance). The Bohr-Sommerfeld quantization rule for momentum, and hence $k$ and $E$, serves to avoid this issue as it is dependent on the length of the well and not on its position (see Quantization of Energy).
The solutions developed in this analysis are complex waves given by
\[ \psi_{1_{n}}(x) = Ae^{\imath k x} \qquad \Big |A \Big | = \sqrt{\frac{1}{L}} \]
or
\[ \psi_{2_{n}}(x)=B^{-\imath kx} \qquad \Big |B \Big | = \sqrt{\frac{1}{L}} \]
with
\[ k_{n} = \frac{n \pi}{L} \qquad n=\pm 1, \pm 2, \pm 3, \dots \]
which give the expected momentum as $+ \hbar k$ and $-\hbar k$ respectively. It is shown that superposition of states of equal energy but opposite direction results in the expectation value for momentum $\langle p \rangle = 0$ (see Superposition).
Indeed, when asked why $\langle p \rangle = 0$, the traditional answer is that the solutions represents a combination of the particle having equal probability of traveling to the right and left within the well. Yet, where in the traditional approach does this superposition of states come about?
In my opinion, the answer lies with the traditional requirement that the value of the solutions is equal to zero at the boundaries of the well in order to maintain continuity. These boundary conditions surreptitiously force the superposition of the two complex solutions into giving a real-valued sinusoidal result.
The issue at hand may be better expressed if it is viewed as follows:
A. The addition of the separate solutions to the Schrodinger Equation.
As a second order differential equation, the Time-Independent Schrodinger Equation results in two separate solutions which will be called $f(x)$ and $g(x)$. The combining of these two solutions in a linear fashion
\[ h(x) = A \cdot f(x) + B \cdot g(x) \qquad A, B \in \mathbb{C} \tag{1} \label{Eq:1} \]
is a necessary mathematical principle to give the general solutions onto which conditions are indeed imposed to get the unique solution(s).
B. The addition of different quantum states.
Two (or more) quantum states can be added together to form a superposed state. The addition of quantum state $\psi_{1}$ and $\psi_{2}$ to give a third state $\psi_{3}$ with
\[ \psi_{3} = c_{1} \cdot \psi_{1} + c_{1} \cdot \psi{2} \qquad c_{1}, c_{2} \in \mathbb{C} \tag{2} \label{Eq:2} \]
with
\[ \Big | c_{1} \Big |^2 + \Big | c_{2} \Big |^2 = 1 \]
is a quantum mechanical principle that is allowed for by the mathematics and discovered by P.A.M Dirac. However, it is not mandated that the quantum states be added together. The superposition is one of choice depending on the initial conditions of the system.
In my opinion, the textbooks seem to imply that the addition of the two solutions for the Schrodinger equation as in Eq.\eqref{Eq:1} is as a result of the quantum mechanical principle of superposition. Instead, this is a mathematical principle and the functions $f(x)$ and $g(x)$ are not quantum states until the appropriate limiting conditions are imposed. Indeed, in the example above, I have refrained from naming them $\psi(x)$ in order to highlight the point.
Once the limiting conditions have been applied, the general equation Eq.\eqref{Eq:1} reduces to a unique solution which represents a quantum state.
The particle in the box is different in that the unique solution actually consists of one of either two equations: $Ae^{\imath k x}$ and $Be^{-\imath k x}$.
Since neither $Ae^{\imath k x}$ or $Be^{-\imath k x}$ can ever be zero, requiring the boundary condition $\psi(x_{0}) = 0$ forces the quantum mechanical superposition unnecessarily at that point. Furthermore, it combines the issue of the mathematical addition of two solutions with the quantum mechanical superposition of two states leading to confusion.
As an example, the traditional real-valued sinusoidal solutions for the particle in the box (e.g. $\psi(x)= A \sin (kx)$) do not have eigenvalues for momentum as this state represents a superposition of two individual states (e.g. $Ae^{\imath k x}$ or $Be^{-\imath k x}$) each of which does possess an eigenvalue.