There are several popular theories about the origin and evolution of flight:
The arboreal theory suggests that birds and bats evolved from tree-dwelling ancestors that gradually developed the ability to glide and then fly.
The cursorial theory posits that birds and bats evolved from ground-dwelling ancestors that gradually developed the ability to run faster and then fly.
The aerial-launch theory proposes that birds and bats evolved from ancestors that were able to launch themselves into the air from the ground or from trees, and then developed the ability to fly.
The aquatic theory suggests that birds and bats evolved from ancestors that lived in the water and gradually developed the ability to fly.
The "trees-down" theory proposes that some animal lineages first evolved gliding or parachute-like abilities in order to safely descend from trees, and only later evolved powered flight capabilities.
These theories are not mutually exclusive, and some researchers believe that different groups of birds and bats may have evolved flight in different ways.