I feel that there is a little inconsistency between the canonical momentum of a classical charged particle in an electromagnetic field and the momentum operator associated to the equivalent quantum system.
Explicitly, let $\vec{A}$, $\varphi$ be potentials for electric and magnetic fields $\vec{E}$, $\vec{B}$. The Lagrangian that describes the motion of a charged particle (of charge $e$) under these fields is
\begin{equation} L(x,\dot{x},t) = \frac{1}{2}m\dot{x}^2 -e\varphi + \frac{e}{c}\dot{x}\cdot\vec{A}. \end{equation}
The canonical momenta associated to $x$ are given by \begin{equation} p_i = \frac{\partial L}{\partial{\dot{x}^i}} = m\dot{x}^i + \frac{e}{c}\vec{A}. \end{equation}
If we perform a gauge transformation \begin{align*} \vec{A}' &= \vec{A} + \nabla\Lambda\\ \varphi' &= \varphi -\frac{1}{c}\frac{\partial\Lambda}{\partial t}, \end{align*} then the canonical momentum transforms as
\begin{equation} p \mapsto p'= p +\frac{e}{c}\nabla\Lambda. \end{equation}
However, in the quantum case, the gauge transformation transforms operators by conjugation with the unitary operator $U(\Lambda) = \exp(\frac{ie}{\hslash c} \Lambda)$. Namely, for the momentum operator, we have \begin{equation} p \mapsto UpU^{-1} = p + [U,p]U^{-1} = p - \frac{e}{c}\nabla\Lambda. \end{equation} Here I used the fact that $[f(x),p]=i\hslash\nabla f$.
Where does this inconsistency come from? I suspect that it has to do with something fundamental about the momentum operator, and how it differs from the classical momentum. Indeed, the canonical momentum depends explicitly on the Lagrangian, so it depends on the dynamics of the problem, but in the quantum case, the momentum operator is just an operator defined on a Hilbert space.
What is the meaning of $p$ and $p'$ in the classical case, and how does it differ from the quantum case?