Let $f$ be a function of three real variables, $(x, y, z)$ where $z$ is a function of $(x,y)$. By the chain rule on $f(x,y,z(x,y))$:
$$\frac{\partial{f}}{\partial{x}}=\frac{\partial{f}}{\partial{x}}\frac{\partial{x}}{\partial{x}}+\frac{\partial{f}}{\partial{y}}\frac{\partial{y}}{\partial{x}}+\frac{\partial{f}}{\partial{z}}\frac{\partial{z}}{\partial{x}}=\frac{\partial{f}}{\partial{x}}+\frac{\partial{f}}{\partial{z}}\frac{\partial{z}}{\partial{x}}$$
But this implies $\frac{\partial{f}}{\partial{z}}\frac{\partial{z}}{\partial{x}}=0$! Which of course can't be true. Something in my understanding is missing. Maybe these are different "kinds" of derivatives?
What is the solution to resolve the confusion?
You problem will become clearer if you note : $$\frac{\partial{f\big(x,y,z(x,y)\big)}}{\partial{x}}=\frac{\partial{f}}{\partial{x'}}\big(x,y,z(x,y)\big)\frac{\partial{x}}{\partial{x}}+\frac{\partial{f}}{\partial{y'}}\big(x,y,z(x,y)\big)\frac{\partial{y}}{\partial{x}}+\frac{\partial{f}}{\partial{z'}}\big(x,y,z(x,y)\big)\frac{\partial{z}}{\partial{x}}.$$ Indeed, you are not differentiating among the same variables : writting $f\big(x,y,z(x,y)\big)=f\circ g(x,y)$ with $g(x,y)=\big(x,y,z(x,y)\big),$ and so $(x,y)\overset{g}{\mapsto}\big(x,y,z(x,y)\big)\overset{f}{\mapsto} f\big(x,y,z(x,y)\big),$ then $x$ is the first variable in the source of $g$ (i.e. $\mathbb{R}^2$) while $x'$ is the first variable in the source of $f$ (i.e. $\mathbb{R}^3$).