$f$ is a scalar field, $f:\mathbb R^3\rightarrow \mathbb R$, i.e $f(x,y,z)$.
Why is $$\nabla f \cdot \nabla f=\lvert \nabla f\rvert ^2\quad? \tag {1}$$
I tried the following, but why are they wrong? $$ \nabla f \cdot \nabla f=\nabla(f\cdot f)=\nabla\lvert f\rvert^2 \tag{2} $$ $$ \nabla f\cdot \nabla f=(\nabla\cdot\nabla)f=\nabla^2f \tag{3} $$
$\nabla f \cdot \nabla f=\nabla(f\cdot f)$ is wrong for the same reason that $\frac{d}{dx} g\cdot \frac{d}{dx} g \neq \frac{d}{dx}(g\cdot g)$ for a function $g:\Bbb R\to \Bbb R$: That's just not how differentiation works with respect to products.
You can do a similar argument to equation 3, as $\frac{d}{dx} g\cdot \frac{d}{dx}g$ clearly isn't $\frac{d^2}{dx^2}g$.
On the other hand, as pointed out in the comments, for each point in $\Bbb R^3$, we have that $\nabla f$ is some vector, and the scalar product of that vector with itself is indeed the square of its length.