What is wrong with this proof that symmetric matrices commute? 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 &amp; 0 \\ 0 &amp; 2 \end{pmatrix} \quad B = \begin{pmatrix}0 &amp; 1 \\ 1 &amp; 0 \end{pmatrix} $$
We then get
$$ AB = \begin{pmatrix}0 &amp; 1 \\ 2 &amp; 0 \end{pmatrix} \qquad BA = \begin{pmatrix}0 &amp; 2 \\ 1 &amp; 0 \end{pmatrix} $$
and indeed these define the same quadratic form:
$$ (x\;\;y)\begin{pmatrix}0 &amp; 1 \\ 2 &amp; 0 \end{pmatrix}\begin{pmatrix}x\\ y\end{pmatrix} = 3xy = (x\;\;y)\begin{pmatrix}0 &amp; 2 \\ 1 &amp; 0 \end{pmatrix} \begin{pmatrix}x\\ y\end{pmatrix} $$
for all $x,y$, but the matrices are different.
Dot product is a relative relationship which summarizes two vectors. A similar relationship is angle. The last statement in your proof amounts to, "because the angle between two vectors is the same, they must be the same vectors," which is wrong.