Foreign policy is also strongly affected by politics. In the United States, the president sets foreign policy, and when a new president comes in, there is often a new foreign policy. What this means is that every four or eight years, foreign policy can shift dramatically, and this leaves the United States, at least, without any consistent plan or trajectory to deal with the world around it. And as if that weren't enough of a problem, while the president sets foreign policy, Congress can refuse to fund foreign policy endeavors, for political reasons, usually, and this further adds to the inconsistency of how the United States functions in the world.
The two main factors that cause foreign policy to change over the years are external factors and internal factors.
At times, the situation in the world can change and foreign policy can change with it. For example, US foreign policy towards the Soviet Union changed as Gorbachev came to power and started his reforms.
At other times, factors within a given country can change, affecting foreign policy. As an example of this, people in the United States got tired of the war in Iraq, thus causing foreign policy towards Iraq to change. This helped to lead to the situation we are now in where we have very few troops in Iraq. The same appears to be happening in Afghanistan.
This is a very broad question... what nations foreign policy are you looking at? Generally speaking, foreign policy changes are a result of changes in a nations interests. What those interests are and how they influence foreign policy depends on the nation.