I understand that naming the composers broadens the question, but I used them as examples, implying that I am interested in understanding if history, if at all, influences the generations of new music styles or writing of music.
It absolutely does. From the very earliest. The development of our written notation, the very foundation of Western musical art as we know it, was part of the larger push by the Carolingians to create a uniform liturgy.
Musicians in the 18th century worked in the service of courts, for rulers who, through music, demonstrated their power and wealth. Court poets fashioned operatic libretti that celebrated the values of the Enlightenment (Metastasio, who was the opera poet in the 18th century, being the most prominent among these). One of the main virtues extolled in these libretti is rational control over the emotions, a concern that is arguably built into the musical language of the 18th century itself.
As for philosophy, it's best to think of that in the following way. Philosophy is inevitably tangled up with humanity's ever-shifting view of the universe and their place in it (though whether it causes these shifts or merely reflects it is another issue). As human understanding changes, the musical language they use to express themselves likewise changes. Thus philosophy has an indirect influence on all musical practice. Specific and direct influence is both more sparse and more difficult to trace. It does crop up in the early 19th century, when composers began to be critics as well and engage in written discourse about music. By the end of the 19th century, someone like Wagner could be actively engaged in philosophical debates (with Hanslick, specifically).
Let's hook you up with some sources:
Susan McClary, "What Was Tonality?" in Conventional Wisdom: The Content of Musical Form
Daniel Heartz, Music in European Capitals: The Galant Style 1720-1780
Mark Evan Bonds, Music as Thought: Listening to the Symphony in the Age of Beethoven
Karol Berger, Bach's Cycle, Mozart's Arrow: An Essay on the Origins of Musical Modernity.
Roger Mathew Grant, Beating Time and Measuring Music in the Early Modern Era
This is a bit too broad to answer. Books can and have been written on this subject, and they're big books! "Real life" can intrude on art in many ways. The amount of money available for art, and who's supplying it, and with what stipulations, from just your patron's taste to actual overt censorship, are some of the easiest ways we can show how the political and social climate effected the work of any of these men. Music also takes inspiration from other art forms, as well as from current events, or from historical events, or from whatever the composer had for breakfast.
Can you say what made you ask this question?