Let's say
$$a'Xa = \begin{bmatrix} a_1 & a_2 \\ \end{bmatrix} \begin{bmatrix} 1 & 2 \\ 3 & 4 \\ \end{bmatrix} \begin{bmatrix} a_1 \\ a_2 \\ \end{bmatrix}$$
By using common differentiation rules, we have:
$$\frac{\partial a'Xa}{\partial a} = 2Xa= \begin{bmatrix} 2a_1+4a_2 \\ 6a_1 +8a_2 \\ \end{bmatrix}$$
However, as $a'Xa$ can also be expressed as
$$a_1^2+5a_1a_2+4a_2^2$$
when we differentiate it w.r.t. $a$, we'll get
$$\begin{bmatrix} 2a_1+5a_2 \\ 5a_1 +8a_2 \\ \end{bmatrix}$$
Any ideas why these two results are different? Thanks so much!