This is well-known material. The group $H^2(M, \, \mathbb{Z})$ classifies *complex* vector bundles on $M$, in other words the transiction functions are assumed to be smooth and with values in $\mathsf{GL}(1, \, \mathbb{C})=\mathbb{C}^*$. In particular, if some power of $L$ is the trivial line bundle and $H^2(M, \, \mathbb{Z})$ is torsion-free, then $L$ itself is trivial *in the topological sense*. *Holomorphic* line bundles on $M$ are instead classified by the Picard group $H^1(M, \, \mathcal{O}_M^*)$. Passing to cohomology in the exponential sequence $1 \to \mathbb Z \to \mathcal{O}_M \to \mathcal{O}_M^* \to 1$, we obtain an exact sequence $$0 \to \mathrm{Pic}^0(M) \to \mathrm{Pic}(M) \stackrel{c_1}{\to} H^2(M, \, \mathbb{Z}),$$ where $\mathrm{Pic}^0(M)=H^1(M, \, \mathcal{O}_M)/H^1(M, \, \mathbb{Z})$ is a complex torus of dimension $q(M)=h^{1, \, 0}(M)$ and $c_1$ is the first Chern class. In particular, if $h^{1, \, 0}(M) >0$ we have a lot of torsion line bundles (in the *holomorphic* sense) even if there is no torsion in $H^2(M, \, \mathbb{Z})$, as the example of complex tori clearly shows.