I have a question about a remark/observation in A Concise Course in Algebraic Topology by P. May at page 199.
Having introduced the Chern classes May claims that $c_1 \in H^2(BU(1); \mathbb{Z})= H^2(\mathbb{CP}^{\infty}; \mathbb{Z})$ corresponds under canonical identification with the identity homotopy class $id_{\mathbb{CP}^{\infty}} \in [\mathbb{CP}^{\infty}, \mathbb{CP}^{\infty}]$.
I don't understand why $H^2(\mathbb{CP}^{\infty}; \mathbb{Z})$ and $[\mathbb{CP}^{\infty}, \mathbb{CP}^{\infty}]$ are identified.
I know that by Yoneda lemma and the fact that $VB_n(-)$-functor of complex $n$-dimensional vector bundles is representable by $[-, \mathbb{CP}^{\infty}]$ we obtain the identification $Hom([-, \mathbb{CP}^{\infty}], H^q(-))= H^q(-;\mathbb{Z})$ explicitely given by $\phi \mapsto \phi_{\mathbb{CP}^{\infty}}(id_{\mathbb{CP}^{\infty}})$.
But I don't see why this identification via Yoneda imply the identification between $H^2(\mathbb{CP}^{\infty}; \mathbb{Z})$ and $[\mathbb{CP}^{\infty}, \mathbb{CP}^{\infty}]$.

$\mathbb{C}P^\infty$ is a $K(\mathbb{Z},2)$ which represents $H^2(-,\mathbb{Z})$. So $$[X, \mathbb{C}P^\infty] \cong H^2(X; \mathbb{Z})$$ for any $X$. Now take $X = \mathbb{C}P^\infty$.
If you want to think of $\mathbb{C}P^\infty \simeq BU(1)$ as the classifying space for line bundles, then this is consistent with the fact that $c_1(\gamma_1)$ is a generator of $H^2(\mathbb{C}P^\infty; \mathbb{Z})$, where $\gamma_1$ is the tautological line bundle over $\mathbb{C}P^\infty$.