It is the same $f(x):=x^2\sum\limits_{k=0}^\infty(\cos x)^k$ than $g(x):=\sum\limits_{k=0}^\infty x^2(\cos x)^k$? It is the same $f(x):=x^2\sum\limits_{k=0}^\infty(\cos x)^k$ than $g(x):=\sum\limits_{k=0}^\infty x^2(\cos x)^k$? 
It seems that $f(0)$ is not defined because $\sum_{k=0}^\infty 1^k=\infty$, however $g(0)=0$! There is something wrong with this reasoning or this is a case where normal arithmetic fails with series?

They are almost the same.  They are the same except when $x=0$.  
If $x=0$ then all terms in $g(x)$ are zero, so $g(0)$ exists and equals $0$.  But the definition of $f(0)$ says:
$$
f(0) := 0^2\;\sum_{k=0}^\infty (\cos 0)^k
$$
which is zero times a divergent series.  So $f(0)$ is undefined.
Now, it is true that $f(x)$ has a removable discontinuity at zero.  So for most purposes setting $f(0)=0$ is what you want anyway.
added
Let me put here another example.  Define
$$
h(x) := \big(1-\cos x\big)\;\sum_{k=0}^\infty (\cos x)^k
$$
Now for $-\pi < x < \pi$ except $x=0$ we have $h(x) = 1$, yet for $x=0$ we have the same undefined
$$
h(0) := 0\;\sum_{k=0}^\infty (\cos 0)^k
$$
Now the natural value is $h(0)=1$.  The difference between $f(0)$ and $h(0)$ is an illustration of the indeterminate form $0 \cdot \infty$.
