Dogwood trees smell in order to attract insects and animals for pollination. Pollination is the process of transferring polling from the male part of the flower, the anther, to the stigma, or female part, thus enabling fertilization.
Studies are still being done as to how and why certain insects and animals are attracted to certain scents. In general, however, musty-smelling flowers tend to attract beetles, while sweet-smelling flowers tend to attract bees and flies. Flowers usually have their strongest scent when they are ready for fertilization, and plants that rely on the same insects have evolved to flower at different times to ensure pollination.