Let $\mathscr{U} \subset \mathbb{R}^n$, $n \in \mathbb{N}$ be an open subset, $f \in \mathcal{C}^2(\mathscr{U}, \mathbb{R})$. Further let $\gamma: (- \varepsilon, \varepsilon) \to \mathscr{U}$ be differentiable infinitely many times for $\varepsilon > 0$ and $\gamma(0) = a$ and $\gamma'(0) = v \in \mathbb{R}^n$. Define $g := f \circ \gamma: (- \varepsilon, \varepsilon) \to \mathbb{R}$.
Since $g$ is $\mathbb{R} \supset (- \varepsilon, \varepsilon) \to \mathbb{R}$, its derivative should be too. I want to apply the one dimensional chain rule to obtain $g'$. This yields $$ g'(x) = f'(\gamma(x)) \cdot \gamma'(x). $$ Since $\gamma': (-\varepsilon, \varepsilon) \to \mathbb{R}^n$ and $f \circ \gamma: (-\varepsilon, \varepsilon) \to \mathbb{R}$ I seemingly have to compose a real number with an $n$-dimesional vector.
The multi-dimensional chain rule goes like this:
This can be rewritten as $J_h(x)=J_g(f(x))\cdot J_f(x)$, where $J_f=\left(\frac{\partial f_i}{\partial x_j}(x)\right)_{ij}$ denotes the Jacobi-matrix of $f$ (or, respectively $g,h$); and $\cdot$ denotes the matrix product.
I will now adapt your notation: In before, your $g$ was my $h$; your $f$ was my $g$; and your $\gamma$ was my $f$.
We have a special case of before. Note that the Jacobi-matrix of $f$ consists of only one row. Namely, $J_f(x)=(\nabla f) (x)=\left(\frac{\partial f}{\partial x_1} , \dots, \frac{\partial f}{\partial x_n}\right)$. Also, let me write $\gamma'(x)=\big(\gamma_1'(x),\dots, \gamma_n'(x)\big)$.
With this notation, $g'(x)=\langle\nabla f(\gamma(x)), \gamma'(x)\rangle$; where $\langle\cdot,\cdot\rangle$ is the scalar product.
This can be rewritten as \begin{equation}\tag{*}\label{*}g'(x)=\frac{\partial f}{\partial x_1}(\gamma(x)) \cdot \gamma_1'(x) + \dots + \frac{\partial f}{\partial x_n}(\gamma(x)) \cdot \gamma_n'(x).\end{equation}
Thus, if $a$ is a critical point of $f$, then $g'(0)=\langle\nabla f(a), \gamma'(0)\rangle=\langle0, \gamma'(0)\rangle=0$.
One can find the second equality by differentiating the expression \eqref{*} again.