I was guilty of that kind of behavior too. We’re social creatures and will repeat what those around us say, sometimes without considering how that might be received - especially when we were young and dumb.
Things have changed culturally since then. It took brave people in marginalized groups to stand up and bring awareness that they did not appreciate having their identities used as pejoratives before a lot of us realized that we were being jerks unintentionally.
We can’t change the past, but we can do better for the future. The fact that you realized that you needed to do better and did is about all one can reasonably expect from a human being.