Look at the first 2 steps of integration. How come the upper limit in the second step is $\displaystyle 2\pi$ instead of $\displaystyle 2a\pi$?
Because the variable has been changed from $\displaystyle x$ to $\displaystyle \theta$ (note, we're now integrating with respect to $\displaystyle \theta$). And the limits are $\displaystyle \theta = 0$ to $\displaystyle 2\pi$.