IMAP (Internet Message Access Protocol) is a method of accessing and storing mail on a mail server. IMAP is defined by RFC 9051.
Basically, when you use IMAP to access your email, then email messages are stored on servers. Whenever you check your inbox, your email client (like Outlook or Apple Mail) contacts the server and lists the email messages and folders (or labels). When you open and read an email message using IMAP, your email client is actually downloading it to your computer so you can read it. In other words, your email client is fetching your message from the email server (Google servers, etc.).
IMAP was designed with the goal of permitting complete management of an email box by multiple email clients, therefore clients generally leave messages on the server until the user explicitly deletes them. An IMAP server typically listens on port number 143. IMAP over SSL/TLS (IMAPS) is assigned the port number 993.