This is because the mateCheck() is a static evaluation, meaning if we call it there are no more moves to calculate and we know we will either get a mate score or a draw score (mate or stalemate).
The mate value is then returned immediately and since the score returned will be negated in the alpha-beta loop by the line:
int eval = -alphaBeta(board, ply-1, -beta, -alpha, localpv);we need the number to be negative to start with.
If we were to return a positive score the engine would think it was losing if it mated the opponent.
Also if we were to return a negative/positive score depending on who did the mating, only one side would try to mate. This is what was happening in Mediocre before I fixed this.