In Empires and Allies, there is one lesson that all great leaders must learn: the enemy never rests. At all points in time your empire is very much in danger, whether it be from warmongers among the Dark Alliance, or your very own so-called friends. A wise and might ruler must understand the need to be alert and on guard at all times, or else his empire would fall to the smallest of invasions.
Of course, a great square-jawed man-amongst-men such as yourself already knows that defending your empire is a necessity, so all that's left is learning how to do just that. In Empires and Allies, keeping your beloved people safe is keeping your buildings safe, and there are two main steps in doing just that:
Build Your Military Force
There's no defending your buildings without having an army to defend them. First you'll need a Barracks, where you can produce Cadet Soldiers, Cannon Artillery, and the Vintage Tank. Each unit is useful in battle and essential for defending against enemy invasions.
Deploy Your Units
Each unit has a certain amount of time necessary to be produced, so first you'll need to wait. When a unit is complete, you can click on the building to deploy it. With the unit selected, you can place it in your empire, much like placing a building. When deploying a unit near a building, a blue square will appear with the word 'Defend'. Buildings within the blue defense squares of any units are being defending by those particular units.
That's all there is to it. Produce military units, then deploy them near all the buildings you want to defend, and you'll be fending off impending doom in no time.