If else statement on join query
UNTESTED - You did not provide any DDL or sample data scripts...
IF is a flow control construct that determines which statement block will be executed.
What you need are Conditional Expressions. In your case, the COALESCE function should do the trick, also look at CASE for non null condition predicates.

SELECT COALESCE(accounts.email, professionals.email) AS Email 
FROM professionals  
LEFT JOIN accounts ON accounts.account_id = professionals.account_id
LEFT JOIN users  ON users.user_id = professionals.user_id;