In the Schrödinger picture, for a "motion" in one dimension, the Hilbert space is typically $$ L^2 (\Omega), ~ \Omega\subseteq\mathbb R.$$ The exact value of this set (interval) $\Omega$ is specified by the dynamical conditions of the problem. This $\Omega$ is linked to the maximal range of the spectrum of the coordinate observable $x$. You have started with $ L^2 ([0,1])$, or more generally $ L^2 ([a,b])$, which tells you that the dynamics restricts the "motion" into a closed interval, which means the quantum particle is trapped, as in the case called "infinite potential well".
So the dynamical conditions fix the Hilbert space. Once you have this Hilbert space, you can try to define self-adjoint operators (which are called quantum observables). If this is possible, everything is ok. If not, then at least the Hamiltonian should be well-defined, in order to define the (Schrödinger) time evolution of states.
Now this $\Omega$ could very well be the whole $\mathbb R$, case in which the momentum operator is self-adjoint on its maximal domain of definition, $D(p)$.
But why can’t I simply use the operator P = -i d/dx without any restriction on the domain?
The domain $\Omega$ is specified by the dynamics, as I said above. For example, a harmonic oscillator can be defined by the condition: the "motion" is unrestricted on the real line, then the Hilbert space is $L^2 (\mathbb R)$, or the "motion" is restricted on the half line, then the Hilbert space is $L^2 (0,\infty)$$L^2 [0,\infty)$, or the "motion" is restricted to the closed interval $[0,1]$. For each Hilbert space, you can check if the Hamiltonian, the coordinate or the momentum are properly defined and self-adjoint.
Regarding the boundary conditions, they are, too, a consequence of the dynamical restrictions. If the particle is trapped in potential well (let us choose the same interval $[0,1]$), then the boundary conditions $\psi (0) = \psi (1) = 0$ on the wave-functions are called physical, or natural, because the operators are differential operators, so it is expected a continuity of the wavefunction at the boundary. Outside of this box it is zero. This condition is not related to the symmetric or self-adjoint character of the momentum, it is given beforehand. Symmetry or self-adjointness are a consequence of this boundary condition, which is enforced on the wave-function in the domain of the operators.