One solution for $$\theta''+\gamma\theta = 0$$ is, for $\gamma>0$,
$$\Theta(\theta) = A\cos \sqrt{\gamma}\theta + B\sin \sqrt{\gamma}\theta$$
My book says that because of the $2\pi$ periodicity of $\theta$ we have that $\sqrt{\gamma} = n\in\mathbb{N}$
The minimal period of the solution is $\frac{2\pi}{\sqrtγ}$. You want that $2\pi$ is also a period of the solution. Thus you need it to be an integer multiple of the minimal period, $$ 2\pi=\frac{2\pi}{\sqrtγ}\cdot n. $$ This is directly equivalent to $\sqrtγ=n$.