Recently, I noticed suspicious activity in my Gmail login, such as logging in with an unknown device. Eventually, I managed to get my Gmail account. What's confusing me is, how did they manage to hack it?

I remembered several sites, so I immediately remembered them and logged in directly through my Gmail.
Does this have a significant impact?
This incident has made me very afraid to use my Gmail account, as some important data is tied to it.
I don't know what else to do after adding two-factor authentication (2FA).
And I'm not really sure, is it really safe?
Have you ever experienced something like this?
What steps did you take, and are they really safe?
Or should I abandon this Gmail account and switch to a new one?