There are two prominent factors responsible for the different shapes of leaves-
(I) Adaptation- Adaptation to the environment is a factor which affects the shape of leaves of different plants. In other words, environment is largely responsible for the shaping of leaves. For instance, the leaves of cactus (which is an aried region plant) are adapted to the dry and hot climate by their reshaping into spines.
(II) Evolution- The shape of leaves is also based on their degree of complexity. That's why leaves are of several types like simple leaf ,compound leaf.
Apart from these simple factors, there are many other reasons why plants may develop different style of leaves. It is a combination of circumstances that finally decide the best leaf shape for a plant. Also as the plant grows, the leaves at the bottom of the plant become less effective as they are shaded by other leaves. The plant therefore lets go or sheds the lower leaves. So leaves need to be easily detachable. Leaves also need to be flexible and must bend easily to give way to passing wind. Otherwise wind force will probably uproot the tree. Therefore leaves are slender at the point they are attached to the stem, to make them flexible and easily detachable.