Why taking derivative of equation sometimes gives gradient and other times tangent? Just as the title says, I am confused by this. 
For example:
For 3D curve $c(t)=(x(t),y(t),z(t)$, tangent is  $(\frac {dx(t)}{dt},\frac {dy(t)}{dt},\frac {dz(t)}{dt})$.
surface $S(a,b)$, tangents are $\frac {\partial S}{\partial a}$ and $\frac {\partial S}{\partial b}$.
But for surface $f$ defined as set of points $p$, s.t. $f(p)=0$, $\nabla f(p) =(\frac {\partial f(p)}{\partial x},\frac {\partial f(p)}{\partial y},\frac {\partial f(p)}{\partial z})$, where $p=(x,y,z)$.
So, why did partial derivatives produce different type of vector for $S$, and $f$? 
What is the rule of thumb in general, when given some parametric or implicit equation, how do I know the type of derivative to take and what will it give me (tangent or gradient/normal) ?
 A: Common derivatives of function $f:X\to Y$ are defined by
$$f'(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}.$$
For this definition to make sense, you need that domain space $X$ is a space with addition ($x+h$), that has $0$ and that has a topology ($\lim_{h\to0}$) and that co-domain space $Y$ has addition ($f(x+h)-f(x)$), can be divided by scalars in $X$ ($h$) and has topology.
Given $X$ a metric field such as $\newcommand\R{\mathbb R}\R$ and $Y$ an algebra or vector space on $X$ (such as $\R^n$) then you have those conditions. (Which does not mean that you can always have a derivate.)  Given that a field $X$ is a vector space over itself this covers common $f:\R\to\R$ functions.
What if $X$ is not a field?  For example, lets have $f:\R^3\to\R$, then the definition will have the following problems:
For $x,h\in\R^3$, then $h\to0$ is well defined by $0=\langle0,0,0\rangle$. Then $f(x+h)\in\R$ and $f(x)\in\R$ and subtraction in $\R$ is well defined,so $f(x+h)-f(x)\in\R$. But there is no definition allowing a real number be divided by a vector $h$.  So the standard definition of derivative does not work in $f:\R^3\to\R$.
An adaptation is made: directional derivatives.  Given $\hat u$ a unitary vector in $\R^3$ then we can define:
$$f_{\hat u}'(\mathbf x)=\lim_{h\to0}\frac{f(\mathbf x+h\hat u)-f(\mathbf x)}{h}.$$
This definition is workable.  It is also workable for $f:\R^n\to\R^m$.
Now, there is an observation that if $\mathbf d=d\hat u$ a non-unitary vector in $\R^3$, then
$$f_{\mathbf d}'(\mathbf x)=\lim_{h\to0}\frac{f(\mathbf x+h\mathbf d)-f(\mathbf x)}{h}$$
is also well defined and $f_{\mathbf d}'(\mathbf x)=df_{\hat u}'(\mathbf x)$ if the limit exists.  Also, if $f$ is soft enough, then $f_{\lambda\mathbf a+\mu\mathbf b}'(\mathbf x)=\lambda f_{\mathbf a}'(\mathbf x)+\mu f_{\mathbf b}'(\mathbf x)$, which means that the directional derivative of $f$ in $\mathbf x$ is a linear trasnformation of the direction vector $\mathbf d$.
Therefor if $f:\R^3\to\R$ has a directional derivative $f'$ in $\mathbf x$, then $f'(\mathbf x):\R^3\to\R$ such as $\mathbf d\mapsto f_{\mathbf d}'(\mathbf x)$ is a lineal trasnformation of $\mathbf d$.
All lineal transformations of $\R^3$ in $\R$ can be defined by a dot product, so $f_{\mathbf d}'(\mathbf x) = \textit{something}_{f,\mathbf x}\cdot\mathbf d$.  That $\textit{something}_{f,\mathbf x}$ is $\nabla f(\mathbf x)$, or the gradient of $f$ in $\mathbf x$.
