You write
$$
f(t) = t^2 = \sum_{n \in \mathbb Z} c_n e^{int}
$$
where
$$
c_k = \frac 1{2\pi} \int_{-\pi}^{\pi} f(t) e^{-ikt} \, dt.
$$
The reason why this makes sense is that if you make the substitution, assuming
$$
f(t) = \sum_{n \in \mathbb Z} c_n e^{int}
$$
for some coefficients $c_n \in \mathbb C$, then you have
$$
\int_{-\pi}^{\pi} \left( \sum_{n \in \mathbb Z} c_n e^{int} \right) e^{-ikt} \, dt = \sum_{n \in \mathbb Z} c_n \int_{-\pi}^{\pi} e^{int} e^{-ikt} \, dt = 2\pi c_k,
$$
because
$$
\int_{-\pi}^{\pi} e^{i(n-k)t} \, dt = \begin{cases} 2\pi & \text{ if } n=k \\ 0 & \text{ otherwise }. \end{cases}
$$
(I didn't justify the switch of the summation and integral but you can still understand that your minus sign needs to be there by looking at that.)
You're saying you got the answer right by putting a minus sign where it shouldn't be, so I expect a sign error in your computations. Can we see the details? Or maybe you can look them up yourself.
(I am VERY confident that this sign should be there ; the idea behind Fourier analysis is all about using the inner product :
$$
\langle f,g \rangle = \int_{-\pi}^{\pi} f(t) \overline{g(t)} \, dt
$$
and the statement that "Fourier analysis works" is just that $\{ e^{int} \, | \, n \in \mathbb Z \}$ is an Hilbert basis of the $L^2$ integrable functions over $[-\pi,\pi]$ under this inner product, hence the $-$ in the decomposition because $\overline{e^{int}} = e^{-int}$.)
Hope that helps,