Commutative property of multiplication (i.e. order of things not mattering in the execution of the operation) is the reason why 5 x 3 is equal to 3 x 5.
If a student does mix the order up when she doesn’t really know/hasn’t heard about the property, then in my opinion, it is less on the understanding capability of the child and more on the way we intend to introduce the difference between equivalence and equality.
The use of “=” for both is rather confusing for a child learning them for the first time and resembles “sleight of hand”. When I was taught mathematics, my teacher ensured we understood the difference you discussed by using another operator to signify equivalence (cannot type here but it had 3 horizontal lines stacked on top of each other, as opposed to two — similar to the programming version you provided).
Back to the example: “While 3+3+3+3+3 is not equivalent to 5+5+5, the result of both these operations is equal to 15, which in turn, is the result that 3x5 OR 5x3 produce by definition!” If the child happens to be a deductive thinker, they would approach the problem backwards from the solution/not totally get why so much emphasis on an ordered multiplication when the result is exactly the same, only to learn later that the order does not matter!
So, strictly speaking, because the “equal to” operator was used, the child was right, in the sense that she systematically defined her own version of a x b contrary to the norm and that was perfectly okay since a x b and b x a, by definition are indeed equal.