You can select a military building and choose the "recruit" button. Once you are in the recruitment screen, you can either use the slider and move it to the right (or left to subtract units) or you can just type in the amount of units you want to recruit in the field on the right of the slider.
 
In the recruitment screen you can recruit any unit of any type (infantry, artillery, cavalry, spy or transport), as long as they are unlocked. Recruitment costs either gold or resources and time. 
 
You can only recruit a certain amount of units at the same time since your military buildings only have a certain recruitment limit. Your farms have a certain unit capacity by type.