Gmail has an option where you can enable IMAP, I'm using G-Suite, so not sure if this is available in the free version or not, but I noticed whether or not I enable this I can connect to Gmail without problems.
I have read that this may be because Gmail naturally runs over IMAP, but then what's the point of having the option to enable/disable it - is there any difference?
Also, I have read there are some security concerns if you enable it - but isn't it working all the time anyway as discovered?
Edit: I am using Thunderbird as an IMAP client to connect to it from my desktop.