Why Does $\cos(z)=\frac{e^{iz}+e^{-iz}}{2}$? 
We defined $$\cos(z)=\frac{e^{iz}+e^{-iz}}{2}$$
  Because $cos(x)$ set values on the $\mathbb{R}$, and due to a theorem, there can be at most one analytic function which get the same values on $\mathbb{R}$

This was on the lecture notes, what does it mean? that if there are 2 analytic functions which agree on $\mathbb{R}$ they will agree on the whole $\mathbb{C}$ plane?
 A: If that's a definition, then there's nothing to worry about: take it or leave it.
However it is justified defining this function over $\mathbb{C}$, because for real $z$ we have
$$
\frac{e^{iz}+e^{-iz}}{2}=\cos z
$$
according to the standard definition of cosine over $\mathbb{R}$ and Euler’s formulas.
The identity theorem tells us that any entire function with the same property (evaluating as the cosine on the real numbers) must be the same.
Identity theorem. Two complex analytic functions that are defined on the same domain and that coincide on a subset having a limit point are equal.
If you work out the Taylor series about $0$ of the given expression, you easily find
$$
\frac{e^{iz}+e^{-iz}}{2}=\sum_{n=0}^{\infty}(-1)^n\frac{z^{2n}}{(2n)!}
$$
which is another way for seeing that we are justified in stating the above definition.
For the same reason it is justified defining
$$
e^z=\sum_{n=0}^{\infty}\frac{z^n}{n!}
$$
even if in the left-hand side there is no exponentiation when $z$ is not real. The notation $e^z$ is not ambiguous when $z$ is real. By the mentioned identity theorem, that's the only way for extending the exponential function from the real numbers to a holomorphic (analytic) function over the complex plane.
