#Java 10, 145 129 107 106 103 93 77 bytes
Java 10, 145 129 107 106 103 93 77 bytes
Loads of bytes saved thanks to @Frozn, and by using Object
as return-type, we can comply with OP's rules of returning the input-array when the array is empty, despite Java's one-return-type-only nature regarding methods.
m->{int f=1;for(var a:m)f=m[0].length!=a.length?0:f;return m.length<1?m:f>0;}
Explanation:
m->{ // Method with integer-matrix parameter and Object return-type
int f=1; // Flag-integer, starting at 1
for(var a:m) // Loop over the rows of the matrix
f=m[0].length!=a.length?
// If the length of the first and current row aren't the same:
0 // Change `f` to 0
: // Else:
f; // Leave `f` the same
return m.length<1? // If there is only one row:
m // Return the input-matrix as result
: // Else:
f>0;} // Return whether the flag `f` is still 1 as boolean