$A$ and $B$ over a ring $R$
Matrices such that $A$ can be transformed into $B$ by a sequence of elementary row-and-column transformations, that is, transformations of the following three types: a) permutation of the rows (or columns); b) addition to one row (or column) of another row (or column) multiplied by an element of $R$; or c) multiplication of a row (or column) by an invertible element of $R$. Equivalently, $B$ is obtained from $A$ by multiplication on left or right by a sequence of matrices each of which is either a) a permutation matrix; b) an elementary matrix; c) an invertible diagonal matrix.
Equivalence in this sense is an equivalence relation.