Question: For any matrix $A$, $A I = I A = A$ ($I$ is the identity matrix).

If $A$ has $m\times n$ dimension, the first identity matrix $I$ that appears in the above equations should have $n\times n$ dimension, while the second identity matrix $I$ should be $m\times m$ dimension. 

Why could the dimensions of the two identity matrices be different? 

In normal cases, shouldn't we say two matrices are not the same if the dimensions of them are different.

Answer: 
You might see this notation because mathematicians, like people, are lazy people and don't want to "waste" time writing everything properly, believing that readers will get what they actually mean.

Sometimes that's no problem, but I think I've seen too many (more than 0) cases where teachers do that and students either don't understand at all, understand something wrong, or start using the notation themselves without realizing they are skipping something.
When I see the notation above, it was because my Linear Algebra textbook was referring to square matrices, so the subscript dimensions were meaningless.