Most ants are not known to fly, but there are some cases when they do. This usually depends on the type of ant, and the role it has in the colony. For instance, the queen usually has wings which can sometimes fall off by molting. The queen needs the wings in order to move from one colony to the next for mating, if this is necessary. An example of this is if the previous colony gets another queen.
The other category of ants that can fly are the male ants. These are usually young ants that are likely to mate in the near future. During mating, the male ants need the wings to do a nuptial dance which is necessary for the mating process.
Typically, the ants swarm from the nest at a particular time of the year in order to mate with a queen. Once this is done, the male ants soon die after mating, and the queen simply loses the wings and starts laying eggs. The ants can also fly to other colonies in order to expand them by mating with the other ants in the nearby colonies.
In summary, it is true that ants can fly, but not all of them do. The ants that fly have this ability for a very specific reason, normally surrounding mating rituals. The next time you see insects that look like ants but which have wings, don’t mistake them for termites. The latter can be identified by their bent antennae and their narrow waists.