Choose your moves carefully.
To secure ourselves against defeat lies in our own hands, but the opportunity of defeating the enemy is provided by the enemy himself.
It's difficult not to panic when you're being shot at.
It may seem an obvious statement, and I don't wish to downplay the severity of real-world situations in which soldiers, police officers and the occasional innocent bystander find themselves involving supersonic hunks of metal flying at them. But as StarCraft 2 is a wargame, and wars involve combat, it's important to remember that combat is going to happen at times inconvenient for you. When our operations get interrupted in real life, we get annoyed. When it happens in a competitive situation, we can get nervous. And when it happens in ways that involve fire and blood, we can panic.
It takes practice, but you can work to downplay this natural reaction, to channel that nervous energy into productive activities. I'm not going to claim to be an expert on this, but there are steps I've taken to minimize the impact of the enemy's plans upon mine, anticipating his moves and doing useful things as much as possible.
Know It'll Happen
You're going to get attacked. Things you build will blow up. Your troops are going to die.
It happens all the time. As Terran playing Protoss or Zerg, it's common to wall off your ramp with a couple Depots and a Barracks. If the alien player's on the ball, some basic units are going to run up the ramp and start taking shots at your buildings. Depending on your rate of production, you may only have a couple of Marines to defend. It's a situation that's bound to happen, so anticipate it if you can.
Likewise, when you gather up enough forces to send against your opponent, they might be ready for it. You might be able to scout them, using scans or spies, and build an appropriate response, but you might get attacked yourself in the meantime. Either way, if you anticipate potentially negative outcomes to your actions, their impact will be less shocking.
So if these things are going to happen, how can we prepare and respond?
Gather Intelligence
From the basic builder scout at the start of the game to the cloaked unit just outside the opponent's front door keeping an eye on his massive forces, intelligence is essential to anticipating what's coming next. A Drone, Probe or SCV zipping around the opposing opening base can give you an inkling as to what they're thinking, and if you tech your way to a cloaked spy or use another, less costly means of observation (a Supply Depot on high ground for example), you can see attacks coming a mile away.
As your play improves you can also use this to your advantage. If your opponent zips into your base and sees you going for a particular build, don't be afraid to change gears on him. And if you attack with a specific unit or group of units and he musters a defense in response, shift to a different type of unit or attack to render his intelligence moot.
Maintain Production
This goes back into the basics I've addressed previously. Always be building something. New means of maintaining your army's supply, tech for your units and new supplements to your existing forces are all good things to invest in. As your macro skills grow, you will find it easier to do this even in the middle of battle.
An exercise I recommend that helped my macro skills greatly isn't necessarily a winning one, but it might surprise you. Practice hotkeying your buildings and switching between them to check your status, and when you attack, use the minimap without watching the fight. I know, it'll be more difficult to see and anticipate what your opponent is doing which directly contradicts what I said in the previous section, but bear with me. Hotkey your main base and production buildings (I put my Command Centers on 4 and Barracks on 5), switch between them and keep pumping out your basic units. When you feel you have an adequate number, for example with your first 4 Marines, use your minimap to A-move your forces to the enemy base.
As they move out, stay focused on your base. Keep producing units even when your expeditionary force comes under attack. Chances are, by the time the last one has expired, you've built twice as many troops. Send those. Keep building and expanding, again, without watching the battles. Attack, lather, rinse, repeat.
I did this after I ended up in Bronze, for a few matches. I was surprised how often my opponents would GG after my fourth or fifth push. Watching replays, it was clear they were trying to tech into a clever solution or were focused on what my Marines were doing, instead of maintaining their production. They panicked, and it was their downfall.
Now, since then, I've panicked a few times. Its a natural reaction, and you can't always prevent it. All I can say is the more you practice, the more you can minimize this reaction. If you know an attack is going to come, get a notion as to where it'll come from and build constantly to respond in kind, even if you feel a jolt of panic when they start chewing your brave soldiers faces off you can probably fight your way through it. The more you do this, the more success you'll have and the faster you'll rise through the leagues in StarCraft 2.