the Fourier transformation of $\cos(x)$, \begin{equation} f(k)=\int_{-\infty}^{+\infty}\cos(x)e^{ikx}dx \end{equation} $1$. on one hand we have \begin{equation} \begin{aligned} f(k)=&\int_{-\infty}^{+\infty}\cos(x)e^{ikx}dx\\ =&\int_{-\infty}^{+\infty}((e^{ix}+e^{-ix})/2)e^{ikx}dx\\ =&\frac{1}{2}(\delta(k+1)+\delta(k-1)) \end{aligned} \end{equation} $2$. on the other hand, we have \begin{equation} \begin{aligned} f(k)=&\int_{-\infty}^{+\infty}\cos(x)e^{ikx}dx\\ =&\int_{-\infty}^{+\infty}(1-\frac{1}{2!}x^2+...)e^{ikx}dx\\ =&\delta(k)-\frac{1}{i^2 2!} \frac{d^{2}}{dk^2}\delta(k)+... \end{aligned} \end{equation} with the fact $$\int_{-\infty}^{+\infty}xe^{ikx}dx=\frac{1}{i}\frac{d}{dk}\int_{-\infty}^{+\infty}e^{ikx}dx=\frac{1}{i}\frac{d}{dk}\delta(k), $$ $$\int_{-\infty}^{+\infty}x^ne^{ikx}dx=\frac{1}{i^n}\frac{d^n}{dk^n}\int_{-\infty}^{+\infty}e^{ikx}dx=\frac{1}{i^n}\frac{d^n}{dk^n}\delta(k).$$
If we take $k=1$, eq. ($1$) gives me $\frac 1 2 \delta(0)$ , but eq. ($2$) gives me $0$, Where did I go wrong?
Technically, what you have arrived at is not 100% wrong, but for a sign error. So if there is a domain for $f$ with radius of convergence greater than one about the origin, then we know that$$f(1) = f(0) + f'(0) + \frac12 f''(0) +\dots$$and similarly $$f(-1) = f(0) - f'(0) + \frac12 f''(0) -\dots$$ hence $$\frac{f(1)+f(-1)}2 = f(0) + \frac12 f''(0) +\dots,$$ and this induces an effective relation that on the right space of functions $f$, $$ \int_{\mathbb R}\mathrm dx\frac{\delta(x - 1) + \delta(x + 1)}2 f(x) = \int_{\mathbb R}\mathrm dx\left[\delta(x) + \frac12 \delta''(x) +\dots\right] f(x) .$$ This space under the integral sign is in some ways the only sense in which the Dirac $\delta$-functions “exist” as functions; we say some limit or some expression is a Dirac $\delta$ when it acts the right way under an integral sign.
You asked this on the Physics Stack Exchange so I felt compelled to take for granted that in fact most of our physics applications concern this “right space of functions $f$,” but now that it has been migrated to the Mathematics Stack Exchange I feel compelled to add that this space of functions is not particularly “normal” for any mathematician to consider when defining a Dirac $\delta$. What you've got is wrong, it’s just not 100% wrong and has some limited applicability.
So basically you assumed that you could distribute the integral over all of this infinite series of terms, collapse each term into a $\delta$-derivative, and then sum over all the $\delta$-derivatives, this manipulation is not 100% well-defined when you have these integrals that don’t actually converge and are being interpreted after-the-fact as existing in some $\int \mathrm dk~f(k)$ term to make them converge; in fact you are making an explicit assumption about this $f(k)$ in order to make this manipulation meaningful.
That assumption in turn is actually even more strong than $f$ just being, say, smooth along the real line; $1/(x^2 + 1)$ is an example of a function which is smooth along the real line but only has radius-of-convergence $1$ about the point $x=0.$ Mathematicians would actually go one further with a bump function, which you could center say at $x=1$ with width $1/2$ and then it and all of its derivatives are $0$ at $x=0$ but it is nonzero on the interval $(0.5, 3.5)$ and so one of these $\delta$-function expressions has a nonzero integral with it from a $\delta(x-1)$ term while the other $\delta$-function expression, which only picks out derivatives at zero, must operate on it to produce zero.