A laboratory can be built in a province to enable you to perform certain magical tasks there. Labs cost most nations 500 gold, and can only be constructed by a mage (a commander with at least one level in one of the eight magic paths, not counting Holy).
A lab is required to recruit mages, perform research, cast rituals, and forge items in that province. Commanders in a lab can exchange items and gems with the nation's treasury; without a lab, they can only trade things with other commanders in that province.
A nation collects gems from magic sites only if it can trace a path from the province with the site through friendly territory to a province with a lab.
Labs have no effect on combat, and aren't specific to a nation; if you capture a province with a lab in it, you can use it.
You will want to build a lab in most of your forts to allow you to recruit mages and do research there.
If you have a large stack of mages as part of an army, and that army finds itself wanting to hold position for a turn or two, it can be helpful to build a lab in the field. This allows those mages to research, reload gems, cast rituals, and pick up magic items forged elsewhere.
Ironically unforted labs have strategic advantages: mages in a fort with a lab can either defend their province or research; mages in a lab outside of a fort can do both at once.