How can I check if a user’s email exists in the database

There’s the email_exists() function that could help you with checking if an email already exists among users.

It’s e.g. used by register_new_user().

More here:

https://developer.wordpress.org/reference/functions/email_exists/

https://developer.wordpress.org/reference/functions/register_new_user/