The best way to combine a trip to Galapagos and Peru is to arrange your trip to Machu Picchu Peru after going to the Galapagos. That’s because you can depart the Galapagos and be in Lima, Peru on the same day. If you do it the other way around you will need to leave an extra night in the Ecuadorian mainland before going out to the Galapagos. When you complete your Galapagos cruise you depart the Galapagos for the mainland.
You can change planes in Guayaquil, Ecuador and fly onto Lima and arrive that same night. You will, however, need to spend a night in Lima before flying on to Cusco and the Valley of the Inca, where Machu Picchu exists.