Certain structures have the ability to automatically fire on enemies. These structures can mostly still be built without a connection to a garrison provider, but will not fire unless they are garrisoned. Garrison providers, like the Forward Base or the Town Hall, provide garrisons to any structures within a radius around them, the specific radius depending on the garrison provider. You can tell if a structure is garrisoned or not by the appearance of its flag, which flies proudly if it is garrisoned but is small and tattered if it is not.
It's common to build garrison providers in certain locations specifically to provide garrisons to defenses.
Losing a Garrison
If a structure is garrisoned when all the garrison providers in range of it are destroyed then it will stay garrisoned for ten minutes, after which it loses its garrison and will not fire on enemies until the garrison is restored.