I think $H^2(M;\mathbb{Z})$ cannot mean the de Rham cohomology group. The coefficients are wrong.
Anyway: $\mathbb{CP}^\infty$ is an amazing space. It is both a model for $K(\mathbb{Z},2)$ and a model of $BU(1)$. Homotopy classes into $K(\mathbb Z,2)$ is in bijection with $H^2(M;\mathbb{Z})$ (By pulling back the fundamental class) and homotopy classes into $BU(1)$ classify (complex) line bundles (by pulling back the tautological bundle). This works well with natural group structures. This gives the required isomorphism.
The cohomology class in $H^2(M;\mathbb{Z})$ corresponding to the complex line bundle is the first Chern class.
I can recommend Milnor Stasheff "characteristic classes" for the classification of the line bundles. I can recommend Hatcher for the classification of cohomology in homotopy classes into $K(\mathbb Z,n)$.