A swarm was a gathering of animals (usually insects) in one location. They could occur for many reasons, such as for defense if they felt threatened. The term could also be applied to any gathering of starships, other artificial objects, or an astronomical event similar to animal swarming.
In 2268, Nilz Baris described a group of twelve Klingons who came aboard Deep Space K-7 as a swarm, although Captain Kirk did not believe "that twelve Klingons constitutes a swarm." (TOS: "The Trouble with Tribbles"; DS9: "Trials and Tribble-ations")
Later that year, while visiting the recreation room with Nurse Christine Chapel, the children rescued from the failed Starnes Exploration Party ran around pretending to be swarm of bees. Mary Janowski warned that the adults better watch out or they will get stung. (TOS: "And the Children Shall Lead")