Comparison operator applied on Matrices returns a MATRIX because it operates item-wise (item by item) and result of comparison is the MATRIX that gives 1 when given (n,k) item is the same or 0 otherwise.

// comparison of matrices results in a matrix!
item_wise_equality = testMX_001 == testMX_002;
// comparison of matrices results in a matrix!
item_wise_inequality = testMX_001 != testMX_002;
printf("%s", MxToString( item_wise_equality ) );
printf("%s", MxToString( item_wise_inequality ) );

Then if() clause applied on entire matrix just checks if matrix exists (and it is not Null).

Both "item by item" equality and inequality matrices EXIST (and they are not Null). Note that Null in AFL is not zero.

Use the DEBUGGER you would see the values

To get better understanding of what is happening in your code and how functions work, use advice given here: How do I debug my formula?

You could use the code like this to do what you wanted:

This will work because MxSum returns a scalar value representing sum of all matrix items. If the above sum is zero it means that inequality check for all elements was false, so all elements have equal value.

When posting the formula, please make sure that you use Code Tags (using </> code button) as explained here: How to use this site.

Code tags are required so formulas can be properly displayed and copied without errors.