One small point...
The way the question is stated, there may be a slight ambiguity. One way (and almost certainly the intended way) to read the question is: given the (periodic) function $\sin^2(x)$, find its Fourier series on the interval $[0, \pi]$. In this case, $(1 - \cos(2x))/2$ is correct.
However, we could also read it as follows: given the function $\sin^2(x)$ defined on the interval $[0, \pi]$, find its Fourier series. In this case, we must first decide how to extend the function to be periodic. Of course the natural choice is to extend it to equal $\sin^2(x)$ for all $x$. Again, the cosine series is correct.
But... we do have the freedom to extend $\sin^2(x)$ to an odd function on $[-\pi, \pi]$ instead, in which case the Fourier series will contain only sine functions (with the coefficients computed in the usual way). The point being that there is in fact another series, featuring only sines, that converges to $\sin^2(x)$ on the interval $[0, \pi]$. Of course, the convergence isn't as fast ;-).
Final Edit: Of course the result you're looking for is just the $L^1$ Inversion Theorem. Below there are some fuzzy thoughts about how IT might be derived from Fourier series - see here for a version of what's below that's an actual proof!
Edit: Thinking about what I said the other day I realized it explains something about the Fourier transform that's always been somewhat mysterious to me. So I'm suddenly enthusiastic about all this. Happens all the time that I learn things by answering MSE questions, but usually regarding things like algebra that I know nothing about, not things I sort of understand, like Fourier analysis. See below...
Original Answer:
Not quite exactly what you're asking for, but it seems to me you should be able to derive Fourier inversion from Fourier series via Poisson summmation. For sufficiently well-behaved functions; this is doubtless going to give a much weaker result than the standard inversion theorem.
Assuming you'd like to work out the details for yourself: If $f\in L^1(\Bbb R)$ and $L>0$ define $$f_L(t)=\sum_{k\in\Bbb Z}f(t+kL).$$Then $f_L$ has period $L$, so it has a Fourier series. Haven't worked it out in detail but it seems clear that (under suitable hypotheses) if you say $f_L$ equals its Fourier series and then let $L\to\infty$ it should follow that $f$ is the inverse tranform of $\hat f$.
Edit, explaining the above a little more explicitly:
Note first that nothing below this line is actual math, quite. The hypotheses are missing - we assume that everything always converges to what it "should" converge to...
For $f\in L^1(\Bbb R)$ define the Fourier transform $\hat f$ by $$\hat f(\xi)=\int f(t)e^{-it\xi}\,dt.$$(Any time you're talking about the Fourier transform you should really include the definition, even in a context where the reader certainly knows the definition, because everyone puts the $\pi$'s in different places; if the reader's definition is a little different things won't look right. This is one reason for the Littlewood Convention, to the effect that $2\pi=1$.)
We're after
$L^1$ Inversion Theorem. Suppose $f\in L^1(\Bbb R)$. If it happens that also $\hat f\in L^1(\Bbb R)$ then $f(t)=\frac1{2\pi}\int\hat f(\xi)e^{it\xi}\,d\xi$ almost everywhere.
Something that Euler or Fourier might have regarded as a proof:
Define $f_L$ as above. Then $f_L$ has period $L$. In our current fantasy periodic functions are always equal to the sum of their Fourier series, so $$f_L(t)=\sum_nc_{L,n}e^{2\pi i nt/L},$$where $$c_{L,n}=\frac1L\int_0^Lf_L(t)e^{-2\pi int/L}.$$Now if you insert the definition of $f_L$ and note that that exponential has period $L$ you see that $$c_{L,n}=\frac1L\hat f\left(\frac {2\pi n}L\right),$$so we have $$f_L(t)=\frac 1L\sum_n\hat f\left(\frac {2\pi n}L\right)e^{2\pi i nt/L}.$$
But $\frac {2\pi}L\sum_n\hat f\left(\frac {2\pi n}L\right)e^{2\pi i nt/L}$ is precisely a Riemann sum for $\int\hat f(\xi)e^{i\xi t}\,d\xi$; since $f_L(t)\to f(t)$ as $L\to\infty$ the theorem follows.
Here's why this seems so cool to me, even though it's really not quite an actual proof: I know the standard proof, or a standard proof, of the Inversion Theorem very well. It's never been intuitively clear to me where the $2\pi$ comes from - some integral has some value, if that integral were different it would be a different constant. But here it's really obvious why the $1/2\pi$ is there: The constants for Fourier series are clear, just because of orthogonality, and the Fourier transform simply inherits the $1/2\pi$ from Fourier series. Ahh, that's better.
So it seems like a worthwhile project to try to concoct an actual proof of IT more or less as above. I can imagine at least two approaches: (i) Show that the argument works for $f_n$, where $f_n\to f$ almost everywhere and $||\hat f_n-\hat f||_1\to0$, (ii) show that the argument actually works assuming just $f,\hat f\in L^1$.
(Of course if we're attempting (ii) we can't show that the Fourier series for $f_L$ converges to $f_L$, since that's simply false in general. But the Fourier series is "summable" to $f_L$...)
Edit: In fact it turns out (i) is not hard - see here. Briefly, assuming $f,f',f''\in L^1$ is enough to make the argument above work, and deriving the full Inversion Theorem from this special case is easy.
Best Answer
Use the fact that $\sin(x)$ is nonnegative on $0 \leq x \leq \pi$, so that your $a_n$ is given by $$a_n = {2 \over \pi}\int_0^{\pi}\sin(x)\cos(nx)\,dx$$ For $n=0$, compute this directly. Otherwise use $\sin(a)\cos(b) = {\sin(a + b) + \sin(a-b) \over 2}$. The Fourier series converges to $|\sin(x)|$ everywhere because it's piecewise continuously differentiable. Plug in $x = 0$ into the Fourier series to get the summation.