If IMAP account did you remove it, then set it up using Other instead of Google, then use browser thathas never gone to gMail.com to get the App PW?
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.
Unable to add Gmail to MacOS mail - Apple Community
Thanks to Bob Sabiston…
iMac says Connection Insecure. Failed to … - Apple Community
Thanks to Webmb…
Sonoma can’t connect to gMail…
I'm no longer receiving mails on my iMac … - Apple Community
GC mac
User level:
Level 1
4 points
Nov 1, 2023 10:12 PM in response to Maggiellv
I also spent hours trying to solve this issue until I followed this video... It worked and my Gmail accounts are back on Mac Mail.
Give it a shot and good luck! https://www.youtube.com/watch?v=U0WPw2TsTAY
It might just need an App Password separate from the gMail password…
The process to add a gmail account to my … - Apple Community
https://support.google.com/a/answer/9003945?hl=en#apple-mail&zippy=%2Cset-up-gmail-with-mail-on-a-mac
Cant create re add Mail
James Walker1 User level:Level 1 (129 points)
Mar 1, 2019 10:39 AM in response to if240
I was having this problem trying to add a mail (not gmail) account just for Notes. In my ~/Library/Keychains folder, I found a subfolder with a long hexadecimal and hyphens name. I deleted that subfolder, logged out, and logged back in. I was then able to add the account, without having lost any passwords from my keychains.