As a reference to insects, "fly" has two meanings.
First, flies are diptera, a specific order of insects. Diptera are called that because they have a single pair of wings. Most insects have two pairs of wings, but in the case of the diptera, the rear wings have evolved into a pair of small organs called halteres that help them balance in flight. These organs are visible on larger diptera, such as crane flies, but, due to most flies small size, are usually not visible. Diptera include house flies, horse flies, and other species that look like what we think of as "flies", but they also include the much larger crane flies, as well as smaller species, such as fruit flies and gnats. House flies are infamous for consuming excrement and carrion, but other types of flies have different dietary habits, and some are important pollinators. All diptera are holometabolist, and have a worm-like larva, the maggot, and enter a pupa before emerging as an adult.
Secondly, the term "fly" is added to the name of many different types of insects that are not closely related to the diptera, such as dragonflies, butterflies, caddisflies and stone flies are all referred to as "flies", despite not being more closely related to flies than to any other insect. A dragonfly is more closely related to a praying mantis than it is to a true diptera.
This can be somewhat confusing, as the biological term does not always match the common term. Some things that look like flies are not, while some things that are flies do not resemble flies.