The flying ants are the breeding ones. They are both male and female. The males are a bit bigger than the workers, the females very much bigger.
The winged males and females fly and mate, then the female "princesses" land, break off their wings, and become queens. They either try to start new nests, or are taken into existing nests of the right species -- or they are eaten by something. The males just die.
In the nest, most ants are workers, which are wholly wingless infertile females. There is also one fertile female, the queen (sometimes several). These live much longer (years) and lay eggs all the time. They store the sperm from their mating flight, and use it sparingly -- they don't mate again.
Termites ("white ants") are not true ants and they do it rather differently.