Both formulas are equivalent, if you are in the electrostatic approximation and your dipole vector does not depend on the position $\mathbf{r}$.
Let's consider the expression $\mathbf{F}=\nabla_{\mathbf{r}}(\mathbf{p} \cdot \mathbf{E})$ which can be easily obtained from the potential energy function
$U=-\mathbf{p} \cdot \mathbf{E}$
and its relation with the force $\mathbf{F}=\nabla_\mathbf{r} U$. Now, recall the vector identity
$\nabla_\mathbf{r}(\mathbf{a}\cdot \mathbf{b})= (\mathbf{a} \cdot \nabla_\mathbf{r}) \mathbf{b}+(\mathbf{b} \cdot \nabla_\mathbf{r}) \mathbf{a} + \mathbf{a} \times (\nabla_\mathbf{r} \times \mathbf{b})+ \mathbf{b} \times (\nabla_\mathbf{r} \times \mathbf{a})$
for $\mathbf{a}=\mathbf{a}(\mathbf{r})$ and $\mathbf{b}=\mathbf{b}(\mathbf{r})$ two arbitrary vectors. For $\mathbf{p}=\mathbf{a} \neq \mathbf{p}(\mathbf{r})$ [independent of the position] and $\mathbf{b}=\mathbf{E}(\mathbf{r}$) we have
$\nabla_\mathbf{r}(\mathbf{p}\cdot \mathbf{E})= (\mathbf{p} \cdot \nabla_\mathbf{r}) \mathbf{E}+(\mathbf{E} \cdot \nabla_\mathbf{r}) \mathbf{p} + \mathbf{p} \times (\nabla_\mathbf{r} \times \mathbf{E})+ \mathbf{E} \times (\nabla_\mathbf{r} \times \mathbf{p})$
As the dipole vector does not depend on the position we can drop the second and the fourth terms. In the electrostatic approximation, Faraday's law reads $\partial_t \mathbf{B}=\mathbf{0}\Leftrightarrow \nabla_\mathbf{r} \times \mathbf{E}(\mathbf{r})=\mathbf{0} $ [this is known as ''Carn's law''] so that the electric field is irrotational and the curl vanishes. Then we can drop the third term and
$\nabla_\mathbf{r}(\mathbf{p}\cdot \mathbf{E})= (\mathbf{p} \cdot \nabla_\mathbf{r}) \mathbf{E}$
so that your definitions agree.
This is best understood by approximating the dipole as a pair of finite charges $\pm q$ separated by a finite distance $d$. In a uniform electric field, the electrostatic forces on each of the charges will cancel out exactly, but in a non-uniform one the forces on the two will be slightly different, leading to a slight imbalance and therefore a non-zero net force. As you take the distance to zero, the difference in electric field goes to zero, but the charge also grows to exactly cancel it out.
To be more quantitative, suppose the negative charge is at $\mathbf r$ and the positive charge at $\mathbf r+d\mathbf n$. The total force is then
$$
\mathbf F=q\left[\mathbf E(\mathbf r+d\mathbf n)-\mathbf E(\mathbf r)\right].
$$
To get the correct form for the limit, change from the charge $q$ to the electric dipole $p=qd$, to get
$$
\mathbf F=p\frac{\mathbf E(\mathbf r+d\mathbf n)-\mathbf E(\mathbf r)}{d}.
$$
The true force on a point dipole is the limit of this as $d\to0$,
$$
\mathbf F=p\lim_{d\to0}\frac{\mathbf E(\mathbf r+d\mathbf n)-\mathbf E(\mathbf r)}{d},
$$
and this is exactly the directional derivative along $\mathbf n$, typically denoted $\mathbf n\cdot \nabla$, so
$$
\mathbf F=p\mathbf n\cdot \nabla\mathbf E=\mathbf p\cdot \nabla\mathbf E.
$$
Best Answer
In a uniform electric field, the net force on an electric dipole is zero because the force on opposite poles acts in opposite directions. But the torque is not zero as the forces are separated by a small distance. This causes rotational effect and the dipole tends to rotate until it aligns itself with the electric field i.e dipole moment and electric field vector are in same direction. Hope this helped.