I have been studying some simple examples of the covariant derivative for 2D surfaces and the way that it is constructed is by taking the usual derivative in the 3D Euclidean space at a point $p$ on the surface and subtracting the component of the derivative that is along the normal vector to the tangent plane at $p$. This gives an "intrinsic" notion of a derivative, i.e. one that entirely has to do with the surface itself by always being confined to the tangent plane of each point.
Now, I was also studying some basic things about the Berry phase and stumbled accross a talk by Haldane who stated that the covariant derivative is defined for a Hamiltonian eigenstate $|n\rangle$ as $$D_\mu|n\rangle=\partial_\mu|n\rangle+iA_\mu|n\rangle$$ $$with\ A_\mu=i\langle n| \partial_\mu |n\rangle$$ But, written out explicitly, this gives $$D_\mu|n\rangle=\partial_\mu|n\rangle-\langle n| \partial_\mu |n\rangle|n\rangle$$ which means that the covariant derivative acting on the state $|n\rangle$ is its "usual" derivative (i.e. the one that acts on the parameter space) minus the component of the derivative that is along the state $|n\rangle$, which seems to be the complete opposite of what we have in the case that I described first, which projects out the components that do not belong to the local tangent plane.
Could somebody explain why do we define the covariant derivative in this way and why is this considered as being intrinsic in the same sense as the first example? In the first example, the covariant derivative was confined to the tangent space of each point $p$, while in the case of the Berry phase, it seems to be confined outside the space in which $|n\rangle$ lives in.
Thank you and please keep the answers at the level of the question. I just need some intuition behind the definition.