It's very important to know the main advantages and the weak points of all StarCraft 2 units, if you want to dominate and win every battle. For most players, this is far from being a walk in the park. In fact to burn this aspect into my brain once and for all, I've been working with a StarCraft 2 units guide.
There are 49 (50 if you consider the Zerg Larvae as units) important units in the game, beginning with the most basic units – the workers (Probes, SCVs and Drones), and ending with the most advanced ones. I'm not going to describe them all here. For that, you should use as well, a complete StarCraft 2 guide.
However, I'm going to put into view 3 examples of balancing an attack, considering the strengths and weaknesses of some of the units in the game.
If you're playing Zerg, you are probably aware of the effectiveness of the Zerg Roach. Roaches are "heavy" tanks, cost-efficient, with thick armor and low range splash damage.
Now, you can use Roaches in two ways. To create a rush attack, case in which they will be the primary damage dealers. This works for early games, especially against Protoss. It's a good idea to bring some Zerglings along in this case, to serve as a meat shield until the Roaches get into position.
Or, you can use Roaches to absorb damage and protect primary damage dealers, like Hydralisks for example.
Siege Tanks are great assault tools for the Terran. They have excellent ranged damage output, especially if opened in steal mode. But for a Siege Tank attack to work, you need to bring on some defenses.
Since Siege Tanks are useless against an aerial attack, you have to bring along aerial defense, in mid or late phases of the game. Thor's or Vikings will do. In early phases, a few Marauders or Marines can serve as a good meat shield.
As a last example, I have to mention that one of the most important things I've learned from the StarCraft 2 units guide was that a Protoss Probe can also be turned into a fierce sword weapon.
If you manage to slip a Probe into the enemy base perimeter, unnoticed, before they lock their base, you can change tactics and start an aggressive Photon Cannon rush, with high chances of winning. Although Photon Cannons are structures, all this tactic has its base on a tiny Probe.
I hope these examples were useful. However, to become a complete SC 2 player, dominate any battle and win almost any match you need much more than that. Here are a few ideas: high APM, great micro skills, know as many strategies as possible and build orders.
However, I strongly recommend you to start out with a StarCraft 2 units guide, to know your battle forces from A to Z, and also be prepared for your enemy's.