Not the angle I'm coming at it from.
I mask as a coping mechanism for ADHD and Social Anxiety. This masking causes me harm. I learned it in the way you describe.
The most helpful learning I've gotten through years of therapy has been to: (1) recognize what I'm doing (2) not beat myself up about it (3) try small steps to change my behavior so that I can feel good about it.
I'm the only person who can unlearn this for myself. I don't blame anyone who masks, and have nothing but empathy for the experience, but I'm proposing they can find a different way.