Hi there you may be interested in /r/musicology asides from being the title of a very groovy Prince album it is the interdisciplinary field that attempts to answer the very question that you pose.
Much of the field has to do with historical trends in music, music theory (think of the harmonies and melodies of music), individual composer's particular tastes and distastes, the instruments used, the technical ability that the instrument is being pushed to achieve, etc.
There's a great deal of musicological work done through comparing to other pieces of music, but other methods are used as well.