There is nothing wrong with your calculations. They are FS of different functions. If we call the even extension of your ##f(x)## by ##f_{even}(x)##, its equation on ##(-1,1)## is$$
f_{even}(x) = \left \{ \begin{array}{r,l}
\frac 1 2,&-1<x<-\frac 1 2\\
-x, & -\frac 1 2 < x < 0\\
x, & 0 < x < \frac 1 2 \\
\frac 1 2, &\frac 1 2 < x < 1
\end{array}\right .$$
Similarly, the odd extension ##f_{odd}(x)## is given by$$
f_{odd}(x) = \left \{ \begin{array}{r,l}
-\frac 1 2,&-1<x<-\frac 1 2\\
x, & -\frac 1 2 < x < \frac 1 2\\
\frac 1 2, &\frac 1 2 < x < 1
\end{array}\right .$$These are both defined on ##(-1,1)## and of period ##2##. If you do the full range FS of ##f_{even}## you will find out that ##b_n=0## and you get only ##a_n## nonzero terms, and ##a_0## is what you have calculated. That's what the half range cosine series is.
If you expand ##f_{odd}## as a full range FS you will find all ##a_n = 0## and only ##b_n##'s are non-zero.
The half range formulas are just shortcuts for these two series taking advantage of the even and oddness. They are two different functions. But note they both represent the same thing on ##(0,1)##.