Numeric output is caused by mean function, not the != operator.
The operator just checks uf prediction matches actual or not, and return a boolean vector. Now, when that is passed to the function, which is really for numeric values only, attempts for coercion. Since TRUE and FALSE can be converted to 1 and 0 respectively, the attempt succeeds and then it's a numeric vector of 1's and 0's. And the output you got is the average of that vector, and it equals the proportion of 1 in the vector.