Because it belongs there? There is no right or wrong because commutativity but I would have put it there as well.
x is a VARIABLE, those belong after their factor, and that is true if that is an expression in parentheses as well. A and B are another kind of variable, they are placeholders, for the concrete problem they are then calculated and replaced with numbers, but x always stays the variable of the equation.
It could be 3x, it could be A(3cosh(B) - 27tan(pi*B)) x, the x still belongs after the expression.