It's due to the new security required by eMail providers.
No telling who your eMail provider is but they all succumb to something like this...
Mac's Mail App is not as modern as iOS's Mail app, Many eMail providers now require a separate App Password different from your eMail password…
If it's an IMAP account, delete it in Sys Prefs Internet Accounts then use "Other" instead of gMail choice to add it.
Most likely biggest factor is using Other in Mail setup, then using a Browser that doesn’t have gMail PW stored init to get the App PW.
It might just need an App Password separate from the gMail password…
Apple mail will not let me add a GMail ac… - Apple Community
https://support.google.com/mail/answer/185833?hl=en-GB
Apple Mail won't sign in to Google account - Apple Community
my iMac has OS Yosemite 10.10.5 Does this… - Apple Community
my iMac has OS Yosemite 10.10.5 Does this… - Apple Community
gmail on mail Version 11.5 (3445.9.1) - Apple Community
gmail on mail Version 11.5 (3445.9.1) - Apple Community
Note from PrestoWebDesign…
Trying to add Gmail account to Apple Mail… - Apple Community
Trying to add Gmail account to Apple Mail… - Apple Community
https://blog.google/technology/safety-security/the-beginning-of-the-end-of-the-password/