Symmetric matrices represent real self-adjoint maps, i.e. linear maps that have the following property: $$\langle\vec{v},f(\vec{w})\rangle=\langle f(\vec{v}),\vec{w}\rangle$$ where $\langle,\rangle$ donates the scalar (dot) product.
Using this logic:
$$\langle\vec{v},AB\vec{v}\rangle=\langle A\vec{v},B\vec{v}\rangle=\langle BA\vec{v},\vec{v}\rangle$$
Where $A$ and $B$ are symmetric matrices. Using the fact that the real scalar dot product is commutative:
$$\langle BA\vec{v},\vec{v}\rangle=\langle\vec{v},BA\vec{v}\rangle$$
We therefore have the result:
$$\langle\vec{v},AB\vec{v}\rangle=\langle\vec{v},BA\vec{v}\rangle$$
This holds true for any real vector $\vec{v}$ so therefore $AB=BA$.
However, symmetric matrices do not always commute so something is wrong with this proof.
You have proved that $v\mapsto v^TABv$ and $v\mapsto v^TBAv$ are the same quadratic form. However, since $AB$ and $BA$ are not necessarily symmetric, that doesn't mean they are the same matrix.
You can check this by plugging in some matrices where you know commutativity fails, for example $$ A =\begin{pmatrix} 1 & 0 \\ 0 & 2 \end{pmatrix} \quad B = \begin{pmatrix}0 & 1 \\ 1 & 0 \end{pmatrix} $$ We then get $$ AB = \begin{pmatrix}0 & 1 \\ 2 & 0 \end{pmatrix} \qquad BA = \begin{pmatrix}0 & 2 \\ 1 & 0 \end{pmatrix} $$ and indeed these define the same quadratic form: $$ (x\;\;y)\begin{pmatrix}0 & 1 \\ 2 & 0 \end{pmatrix}\begin{pmatrix}x\\ y\end{pmatrix} = 3xy = (x\;\;y)\begin{pmatrix}0 & 2 \\ 1 & 0 \end{pmatrix} \begin{pmatrix}x\\ y\end{pmatrix} $$ for all $x,y$, but the matrices are different.