This is true for any theory with equality and a binary operation *. That is, this is a corollary of equality axioms as opposed to axioms describing any particular theory, such as theory of groups, rings or vector fields. Equality axioms are usually considered the common basis of all theories, along with such axioms as "A and (A -> B) imply B."

Note that scalars (e.g., real numbers) and matrices do indeed form a ring, but vectors do not because of multiplication. The dot product maps two vectors into a number, not a vector, and the cross product is not associative, nor does it have a multiplicative identity. Vectors are usually considered to be a vector space over a field or its generalization, a module over a ring. In this case, multiplication takes two objects of different type: a scalar and a vector.