There are two reasons why a structure might be shaped similarly in two different objects.  One is that the structure is analogous, meaning that it performs the same function.  The wings of a dragonfly and of a bird are analogous, and, in fact, are also analogous to the wings of a 747.  In order to fly an object needs to generate lift.  This is easily done (in various ways) by having large flat surfaces project out from both sides of the object.  Therefore flying things have such structures.

But knowing the function of a structure doesn't necessarily tell us all we want to know about why the structure exists.  Part of why a wing exists is to perform a certain function, but part of it lies in the construction of the wing.  Perhaps this question is better worded as HOW the wing came to be rather than WHY it came to be.  The picture below shows the basic structure of the limbs of several vertebrates.  Notice that all the limbs, whether wings, legs, arms, or flippers are built upon the same basic structure. (Diagram from Monroe and Wicander, The Changing Earth, 3rd Edition.)

ALL vertebrate limbs are put together this way, regardless of their use.  Clearly there is no analogous similarity between a bat's wing and a horse's leg, and the extreme difference in uses of the two makes the underlying similarity seem unusual.  These types of similarity are called homologous and are very interesting indeed.  

Biologists generally find depictions of angels absurdly funny because they have two sets of forelimbs.  Bird wings are homologous to human arms, not completely different structures.  Angels would necessarily have two tibia, two radii, two ulnae, and more than five sets of digits if they really looked like that, not to mention all the attachment bones that would have to be duplicated in the torso, like shoulder blades and collar bones.  Then there would have to be two sets of muscles, a huge sternum and keel, ...  Even wimpy angels would be barrel-chested individuals indeed!  Pegasus, the flying horse of Greek myth, represents the same basic misunderstanding of anatomy.