What am I doing wrong, differential equation

We're looking for $\displaystyle x(t)$. The data are : $\displaystyle x'=f(t,x)$, $\displaystyle x(0)=0$.

We have $\displaystyle f(t,x)=1+x^2$.

I rewrite it as $\displaystyle \frac{dx}{dt}=1+x^2$. Which is equivalent to $\displaystyle 1=\frac{dx}{(1+x^2)dt}$. Equivalent to $\displaystyle \int dt=\int \frac{dx}{1+x^2}$. Which means that $\displaystyle t=arctan(x)$. As we were looking for $\displaystyle x(t)$, from what we got it's easy to see that $\displaystyle x(t)=tan(t)$. $\displaystyle x(0)=0$ is satisfied.

Now looking at the beginning, we had that $\displaystyle x'(t)=1+x^2$. What I'm missing to understand is how my solution works here? If I derivate $\displaystyle tan(t)$ I won't get the $\displaystyle 1+x^2$. I'm confused.