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.