A projection operator \(\hat{P}\) is a linear operator that transforms a vector in the direction of another vector, i.e., it projects one vector onto another.

In general,
$$\hat{P}=\vert\boldsymbol{u}\rangle\langle\boldsymbol{v}\vert$$
$$\hat{P}\vert\boldsymbol{w}\rangle=(\vert\boldsymbol{u}\rangle\langle\boldsymbol{v}\vert)\vert\boldsymbol{w}\rangle=\vert\boldsymbol{u}\rangle(\langle\boldsymbol{v}\vert\boldsymbol{w}\rangle) =c\vert\boldsymbol{u}\rangle$$
where \(c\) is a scalar.
It is useful in quantum mechanics to have a projection operator that maps a vector onto another vector, which is part of a complete set of orthonormal basis vectors \(\left \{\boldsymbol{i} \right \}\) in a Hilbert space. We define the operator as:
$$\hat{P}_{\boldsymbol{i=\boldsymbol{m}}}=\vert\boldsymbol{m}\rangle\langle\boldsymbol{m}\vert$$
This allows us to project a vector \(\boldsymbol{w}\) onto the basis vector \(\boldsymbol{m}\):
$$\hat{P}_{\boldsymbol{i=\boldsymbol{m}}}\vert\boldsymbol{w}\rangle=\vert\boldsymbol{m}\rangle\langle\boldsymbol{m}\vert\boldsymbol{w}\rangle=c\vert\boldsymbol{m}\rangle$$
If \(\boldsymbol{w}\) is a wavefunction \(\psi\) that is a linear combination of a complete set of orthonormal basis functions, i.e., \(\psi=\sum_{i=1}^{N}c_i\phi_i\), then
$$\hat{P}_i\psi=\vert\phi_i\rangle\langle\phi_i\vert\psi\rangle=c_i\phi_i$$
When we measure an observable of a system whose state is described by \(\psi\), we get an eigenvalue corresponding to an eigenfunction, which is one of the orthonormal basis functions in the complete set. We say that the wavefunction \(\psi\) is projected onto (or collapsed into) the eigenfunction \(\phi_i\).