There is a leading space in the definition of \endpmatrix in amsmath:
This is certainly an accidentally missed
% (alike definitions do not have it and it is the single occurrence of
{\n in amsmath). Evidently, it has no effect in math mode. Nevertheless, it does not belong there.