The two spectra should be the same, as (2b) and (3b) indicate. These two equations should lead you to the same result.
You compare (2a) with (3a). That's wrong because you don't take into account the sign before $\theta$ of the initial equation.
First, your function considered on each of the intervals $[0,T/2[$ and $[-T/2,0[$ separately, is just a constant function. It's the whole that is non-constant. So, when you integrate, since you can separate out your integration over the different integration intervals, on them, you are just integrating a constant function.
So, $f$ didn't disappear, $f$ is just equal to $1$ over the interval $[0,T/2[$.
Second, your function is also odd. The constant term is found by simply integrating the function over an interval symmetric around the origin.
$$a_0=\frac{2}{T}\int_{t=-\frac{T}{2}}^{t=\frac{T}{2}}f(t)\,\mathrm{d}t=\frac{2}{T}\int_{t=-\frac{T}{2}}^{t=0}f(t)\,\mathrm{d}t+\frac{2}{T}\int_{t=0}^{t=\frac{T}{2}}f(t)\,\mathrm{d}t \\ =\frac{2}{T}\int_{t=-\frac{T}{2}}^{t=0}-1 \, \,\mathrm{d}t+\frac{2}{T}\int_{t=0}^{t=\frac{T}{2}} 1 \, \,\mathrm{d}t = 0 \; .$$
Therefore the integral is zero.
EDIT: $$\begin{eqnarray}\int_{t=-\frac{T}{2}}^{t=\frac{T}{2}}f(t)\,\mathrm{d}t & = & \int_{t=-\frac{T}{2}}^{t=\frac{T}{2}} \left(\frac{a_0}{2}+ \sum_{r=1}^{r=\infty} a_r\cos\frac{2\pi r t}{T}+b_r\sin\frac{2\pi r t}{T}\right)\,\mathrm{d}t\\
& = & \int_{t=-\frac{T}{2}}^{t=\frac{T}{2}} \frac{a_0}{2}\,\mathrm{d}t+ \sum_{r=1}^{r=\infty} a_r \int_{t=-\frac{T}{2}}^{t=\frac{T}{2}}\cos\frac{2\pi r t}{T}\,\mathrm{d}t+\sum_{r=1}^{r=\infty}b_r\int_{t=-\frac{T}{2}}^{t=\frac{T}{2}} \sin\frac{2\pi r t}{T}\,\mathrm{d}t \\
& = & \int_{t=-\frac{T}{2}}^{t=\frac{T}{2}} \frac{a_0}{2}\,\mathrm{d}t+ \sum_{r=1}^{r=\infty} a_r \cdot 0+\sum_{r=1}^{r=\infty}b_r\cdot 0 \\
& = & \int_{t=-\frac{T}{2}}^{t=\frac{T}{2}} \frac{a_0}{2}\,\mathrm{d}t \\
& = & \frac{a_0}{2}\cdot T
\end{eqnarray}$$
Best Answer
As the function is even, all the sine coefficients will be zero and we can integrate from $0$ to $\pi$ and double. Then
$$2\int_0^{\pi/2}\cos(kx)\,dx-2\int_{\pi/2}^\pi\cos(kx)\,dx=\frac{\sin(k\frac\pi2)-0-0+\sin(k\frac\pi2)}k$$