You're basically at the verge of discovering an interesting relationship between Fourier series and Taylor series that only really comes to light when you consider complex functions! In the process, you're coming very close to deriving a special case of the Cauchy Integral Formula, which you will be covering eventually in your complex analysis class.

Consider the complex function $f(z)$. If it is analytic, it can be expanded in a Taylor series as
$$
f(z) = \sum_{n=0}^{\infty}c_nz^n,
$$
where $c_n$ can be evaluated either as
$$
c_n=\frac{f^{(n)}(0)}{n!},
$$
as per the normal Taylor series definition, or as
$$
c_n=\frac{1}{2\pi i}\oint_C\frac{f(z)}{z^{n+1}}dz,
$$
via Cauchy's integral formula; the integral here is a contour integral in the complex plane along the curve $C$ that must bound a region that contains $z=0$.

Now, we can evaluate the function $f$ on the circle of radius $r$ centered on the origin by taking $z=re^{i\theta}$, in which case
$$
f(re^{i\theta}) = \sum_{n=0}^{\infty}c_nr^ne^{in\theta}.
$$
We can also choose the special case of $C$ to be this very same circle, in which case
$$
c_n=\frac{1}{2\pi i}\oint_{C(0,r)}\frac{f(z)}{z^{n+1}}dz
=\frac{1}{2\pi i}\int_0^{2\pi}\frac{f(re^{i\theta})}{r^{n+1}e^{i(n+1)\theta}}(ire^{i\theta})d\theta
=\frac{1}{r^n}\frac{1}{2\pi}\int_0^{2\pi}
{f(re^{i\theta})}{e^{-in\theta}}d\theta,
$$
and so
$$
c_n=\frac{f^{(n)}(0)}{n!}
=
\frac{1}{r^n}\frac{1}{2\pi}\int_0^{2\pi}
{f(re^{i\theta})}{e^{-in\theta}}d\theta.
$$
Identifying $g(\theta) = f(re^{i\theta})$ as a function periodic on the interval $[0,2\pi]$, we can see that this is exactly the expression for the Fourier coefficients of $g$ on the interval $[0,2\pi]$, (up to the factors of $r^n$, which anyway cancel out when this expression for $c_n$ is plugged into the Taylor expansion of $f(re^{i\theta})$ above).

If you come at this from the opposite direction, where you are computing the Fourier series and Taylor series of some suitably nice function $g(z)$, then you can reverse this argument, starting from
$$
g(\theta) = \sum_{n=-\infty}^{\infty}c_ne^{in\theta},
$$
where
$$
c_n = \frac{1}{2\pi}\int_0^{2\pi}e^{-in\theta}g(\theta)d\theta.
$$
By taking the viewpoint that we are actually integrating along the unit circle on the complex plane, parameterized by $z=e^{i\theta}$, then we can write
$$
g(\theta) = \sum_{n=-\infty}^{\infty}c_n(e^{i\theta})^n = \sum_{n=-\infty}^{\infty}c_nz^n = f(z),
$$
and
\begin{align}
c_n &= \frac{1}{2\pi}\int_0^{2\pi}e^{-in\theta}g(\theta)d\theta
= \frac{1}{2\pi i}\int_0^{2\pi}\frac{g(\theta)}{e^{i(n+1)\theta}}(ie^{i\theta})d\theta\\
&=\frac{1}{2\pi i}\oint_{\textrm{unit circle}}\frac{f(z)}{z^{n+1}}dz
\end{align}
(by essentially reversing what we did above).

Along the way, we've discovered an important generalization of Taylor series that includes \emph{negative} powers of $z$ as well! This is called a Laurent series. We can no longer interpret all of the coefficients as coming from derivatives of the function $f$, because in fact the derivative is undefined at $z=0$, except for the case where all the negative-power terms vanish, and we're left with the standard Taylor series.

Finally, for each identification of the Taylor/Laurent series with the the Fourier series, you can take the real and imaginary parts of both sides to get something like the expression that is in the OP. The only trouble with the expressions in the OP is that the integrals should be \emph{definite} integrals over the interval $[0,2\pi]$, because that's what allows the integral to pick out one term in the Fourier expansion (i.e., the particular cosine and sine functions form an orthogonal set on that interval). Thus, there should be no left over $\theta$'s in the expressions. In addition, the expansion coefficients are not necessarily real, and so picking out cosine term as being the real part of the Taylor expansion isn't completely justified.