I took acting classes for two years. I was 10 years old and extremely shy. My parents figured out it would help me open up. It did, eventually.
Being shy is being preoccupied with what people think. It's mirroring the persons in front of us in an effort to please them, or at least to not antagonize them.
Shyness is a form of fear. It's an attempt at avoiding conflicts by repressing self-expression. Revealing yourself is uncomfortable and can be perceived as a threat, so shutting yourself down becomes a defense mechanism.
Acting is putting on a mask. It's forging yourself a second identity. When you're up there on stage, you're not really yourself. And when you're free to be anyone, you're free to do anything: you can say the most random things in front of a public and nothing will happen to you. Quite the contrary in fact: you will receive rounds of applause.
That's how I think I internalized the idea that being yourself isn't dangerous: if nothing happens to me when I play a role, why would it be different for the real me?
I stopped attending classes after moving to a different city, but I would sporadically join an acting group organized by the school I was attending. I loved improvisation exercises: the more random you act, the funnier it is for everyone.
By the time I left university, shyness wasn't an issue anymore. Talking non-sense to a complete stranger in a bar? Easy. Asking random girls to write down their phone numbers on my body for fun? Yes, we can. Performing a naked run in front of 30 students? Check.
Don't get me wrong, I didn't become an extrovert and I still need as much alone time as possible. However, introversion and shyness are two different things: the latter can be overcome with practice.