how do rock formations form