Some things I picked up over time. Other things, I studied about. I read about body language that helps elicit trust, like eye contact. I've also practiced different things (like trying to look casual by leaning on things, or professional with good posture, etc) with different people and studied the way people reacted to me. At work I have to be very conscious of the professional setting in order to keep my back straight up, smile, look people in the eye, sound cheery and confident, etc. I often can't figure out what the best thing to do with my arms is, though. Keeping them at my sides feels awkward, and crossing my chest would come across as a "keep away" signal. I usually end up clasping my hands together in front of my hips as a way to look friendly yet still feel comfortable.
It's much easier when I'm with a friend/some friends and can just be myself. They don't get offended if I cross my chest or stare off into the distance. Though usually I'm smiling of my own accord then, because I'm having genuinely fun.
So yeah, studying and practicing, that's how I got it. I still have trouble regulating my tone of voice, apparently, since I still get complaints sometimes for having "an attitude". But that seems to be something that I'll just never understand, at this rate.