The rank of a matrix is the maximum number of linearly independent row vectors of the matrix.
A matrix (A1) is said to be row equivalent to a matrix (A2) if A1 can be obtained from A2 by carrying out elementary row operations. The row equivalent matrices have the same rank. The rank of a matrix doesn't change under elementary row operations.
Once the matrix is in row-echelon form, the number of nonzero rows can be counted, which is precisely the rank of the matrix.