Gradient vector for a function of two variables For the function $z = x^2 + y^2 , z = f(x,y)$
the gradient comes out to be $(2x,2y)$.
However since the function is in 3D , shouldn't the gradient also be a 3D vector?
How would the gradient change if $w = f(x,y,z) = x^2 + y^2 -z =0$?
Will it be $(2x,2y, -1)$?

Maybe you confuse $f$ with its graph. The graph of $f$ is three dimensional, i.e., a subset of $\mathbb{R}^3$. But $f$ has only two entries. For every partial differentiable function $f = f(x, y)$ the gradient of $f$ is defined as $(\partial_x f, \partial_y f)$, so the gradient is a planar vector in this case.
If you consider $w(x, y, z) = x^2 + y^2 - z$, then $w$ depends on three variables and therefore the gradient is a three dimensional vector $(\partial_x w, \partial_y w, \partial_z w) = (2x, 2y, -1)$. 
In the most general case, if $g = g(x_1, \dots, x_n)$ is a function of $n$ real variables, then $g$ has a graph 
$$\Gamma = \{ (x_1, \dots, x_n, y) : y = g(x_1, \dots, x_n) \} \subseteq \mathbb{R}^{n + 1}$$
and a gradient 
$$\nabla g = (\partial_{x_1} g, \dots, \partial_{x_n} g) \in \mathbb{R}^n.$$
