How were the Andes formed?

The Andes were formed due to compressional (or squashing stress) due to the presence of convergent plate boundary just off the western coast of the continent of South America. Here the oceanic crust of the Nazca plate is being forced against the continental crust which forms the continent of South America. The collision causes stress to build up which in turn causes deformation and uplift of the continental crust forming fold mountains (in this case the Andes).

Meanwhile the denser oceanic crust is forced under the continental crust back into the mantle. This process is known as subduction and generates magma, which rises towards the surface forming volcanoes which in turn contribute to mountain building.