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.


With the same reasoning you can prove that for any square matrix $A$ it holds that $$\langle Ax,x\rangle =\langle A^T x,x\rangle.$$ You can't conclude that $A=A^T$ from here (you could if you would have $x$ and $y$ but that does not work).

So the thing is that the quadratic form $x\mapsto \langle Ax,x\rangle$ only determines the symmetric part of the matrix, but not the full matrix.