This question is fundamental to historiography, which is, in one limited sense, the history of how history has been written. To use American history as an example, during the early part of the twentieth century (and really until the Second World War) many intellectuals were struck by the growing economic inequality in the United States. Influenced by Marx and other theorists, the history they wrote tended to emphasize the role of elites in exerting control over the United States has a whole. One of the most famous of these historians, known as the Progressive School, was Charles Beard, whose book An Economic Interpretation of the Constitution of the United States argued that the framers of the Constitution were motivated more by economic motives (i.e. maintaining their wealth and status) than by ideas or convictions about liberties. Beard wrote many other books along similar lines with his wife, Mary. Similarly, Carl Becker argued that the American Revolution was as much a struggle over "who would rule at home" as it was about "home rule." This is only one example of how historians are influenced by the times in which they write. There are many others.
The advent of the Cold War was the context for what has become known as "Neo-Whig" history, which placed an emphasis on ideas, and the turmoil of the 1960s, for example, gave rise to the New Left historians, who became more interested in writing "history from below" than in studying traditional political and diplomatic history. Similarly, the now-classic cultural formulations of "race, class, and gender" studied by almost all historians are related to modern social concerns, as is the emerging field of environmental history.
Historians can also be influenced by other factors. It was not just the social concerns of the era that unleashed a flood of "history from below" in the 1960s and 1970s. It was also the advent of the computer, which enabled historians to collate and make sense of vast amounts of demographic data and non-traditional sources that could shed light on the behavior of non-elites. Additionally, advances in other fields, such as anthropology and sociology have led to new ways of thinking about history. To quote historian Bernard Bailyn, writing about the emergence of the "Atlantic World" as a category for historical analysis, developments in the field of history has often involves a process in which "the external, public orientations of historians' thought" have "merged with the internal propulsions of scholarship, the inner logic of historical inquiry." This dynamic has always been fundamental to the development of the discipline.
Source: Bernard Bailyn, Atlantic History: Concepts and Contours (Cambridge, Mass: Harvard University Press, 2005)29-30.