All ants live in colonies, consisting of an egg-laying female (queen), short-lived males, and workers (sterile females). The ants you see foraging in your garden or kitchen are workers. Workers that find food communicate with other workers by depositing a chemical message on the substrate as they crawl back to the nest. Although we cannot smell it, this "trail pheromone" sticks to the substrate for long periods of time and helps other ants find the food at the end of the trail.
In the spring, ants develop wings and fly to new locations and invade homes to forage for food or to establish a new nest.
Source: University of Nebraska - Lincoln