In Calculus of Several Variables, Third Edition, by Serge Lang, this is exercise 1 in chapter 6, section 5:
Let $f$ be a function of two variables. Assume that $f(O) = 0$, and also that $f(t P) = t^2 f(P)$ for all points $P$ in $\mathbb{R}^2$. Show that for all points $P$ we have $f(P) = \frac{(P \cdot \nabla)^2 f(O)}{2!}$.
Section 5 is on Taylor's formula. I'm guessing that it should be assumed that $f$ has continuous partial derivatives up to order 3 so that the Taylor expansion at $O$ up to degree 2 can be calculated. So, $f(P) = f(O) + (P \cdot \nabla)f(O) + \frac{(P \cdot \nabla)^2 f(O)}{2} + \frac{(P \cdot \nabla)^3 f(\tau P)}{6}$ for some $\tau \in [0, 1]$.
Using the chain rule, we get $\frac{d}{dt}f(t P) = \frac{d}{dt}\left[t^2 f(P)\right] \iff \nabla f(t P) \cdot P = 2 f(P)t \implies P \cdot \nabla f(O) = 0 \iff (P \cdot \nabla)f(O) = 0$. Thus, the Taylor expansion simplifies to $\frac{(P \cdot \nabla)^2 f(O)}{2} + \frac{(P \cdot \nabla)^3 f(\tau P)}{6}$. How can it be shown that $\frac{(P \cdot \nabla)^3 f(\tau P)}{6} = 0$?
Temporarily define $g: \Bbb{R} \to \Bbb{R}$ by $g(t) = f(tP)$. Then, by the standard Taylor's theorem in single variable calculus, using the Lagrange form of the remainder, we have that \begin{align} g(1) &= g(0) + g'(0) (1-0) + \dfrac{g''(0)}{2!}(1-0)^2 + \dfrac{g'''(\tau)}{3!}(1-0)^3 \tag{$*$} \end{align} for some $\tau \in [0,1]$. Now, note that $g(t) := f(tP) = t^2f(P)$. So, we have that for any $t \in \Bbb{R}$, \begin{align} \begin{cases} g'(t) &= 2t \cdot f(P) \\ g''(t) &= 2f(P) \\ g'''(t) &= 0 \end{cases} \end{align} In particular, $g(0) = g'(0) = g'''(\tau) = 0$. Hence, equation $(*)$ reduces to $g(1) = \dfrac{1}{2} g''(0)$. But, $g(1) = f(P)$, so we now have that \begin{align} f(P) = g(1) = \dfrac{1}{2}g''(0). \end{align} Now, once again, recall that $g(t) = f(tP)$; this time compute the second derivative of $g$, but using the chain rule. You'll find that \begin{align} \dfrac{g''(0)}{2} = \dfrac{1}{2} \left( P \cdot \nabla \right)^2f (O). \end{align} Hence \begin{align} f(P) = \dfrac{1}{2}\left( P \cdot \nabla \right)^2f (O). \end{align}
So, more directly, you can verify that \begin{align} g'''(\tau) = \left( P \cdot \nabla \right)^3f (\tau P), \end{align} and by what I showed above, $g''' = 0$. Hence, this term vanishes.
Also, now it should be easy enough to prove the following generalization: