Reasons for Reagan:He decided to initiate talks with the USSR on arms limitations and a renewed 'detente' like state between the countries. Capitalism won over Communism as it proved itself to be the dominant economic and political system (See: The Last Man by Fukuyama), Reagan leading a 'strong' USA that wasn't crippled by economic burden or mass discontent allowed it to thrive as the USSR collapsed. Calling for an abolishment of the Cold War publically ignited the sentiment globally (Mr. Gorbachev, tear down this wall! in reference to Berlin).
Reasons for GorbachevGlasnost and Perestroika generally made the USSR more liberal and began a chain reaction of revolutions and changes, such as the stagnant economy collapsing further, that led to the end of the Cold War. Agreeing to arms reduction talks and conferences (e.g. Washington, Moscow, Malta) whereas his predecessors were always reluctant or refused to make progress on this issue.It was not Reagan due to his hatred of the USSR as demonstrated in his 'Evil Empire' speech that shifted tensions negatively, his 'Star Wars' plan that targeted the USSR despite arms limitation talks commencing at the time, and Able Archer 83.