Custom registration function not working as it should because is_mail and email_exist keep giving errors when it shouldn’t

Because there is context lacking I’m not able to fix all your problems. One of the mistakes I see is that in your code this line:

if (email_exists($email) === false) {
    $errors[] = 'E-mail address is already in use.';
}

Must be:

if(email_exists($email)){ etc.

Because you check whether the email_exists function returns an ID when it exists (translates in true) or does not exist, which will give false. Could you give more context (e.g. the form in HTML) for the rest of your question?

EDIT: you make the same mistake with username_exists($username) === false which should just be if(username_exists($username)) instead. Same logic applies.

EDIT EDIT: oh, actually you do that mistake more. Also with in_array( $username, $invalid_usernames ) === false must be: in_array( $username, $invalid_usernames ) Now you are checking the exact opposite of what you want to check I suppose.