Spoiler warning: Plot and/or ending details follow.
A colony is a settlement that is established on a planet by a spacefaring race not native to that planet. Colonies can serve different purposes for different races, such as agricultural colonies, scientific colonies, or commercial colonies.
Colonies of the United Federation of Planets usually start out as small communities with a population of a few hundred. In some cases colonies started out as United Earth Starfleet or Federation Starfleet outposts and a civilian colony eventually grew up alongside the outpost. For example, the colony on Tarsus IV began as a Starfleet outpost in the 22nd century. Many colonies eventually expand to hold hundreds of thousands or even millions of individuals, and may join the Federation themselves as full members.
Worlds were carefully evaluated to ensure that they would be habitable for the intended populations. This included ensuring that the ecosystem would be able to handle a new population successfully. (DSC novel: Drastic Measures; TOS novel: Burning Dreams)
In addition to establishing colonies on pre-existing Class M worlds, the Federation also terraformed a large number of suitable worlds to Class M standards to make them suitable for colonization. (TNG episode: "Home Soil"; DS9 episode: "Second Sight"; SCE eBook: Ishtar Rising, Book 1)