Hi KatG! Welcome to the forum!
To get from Madrid airport to SJPP you have several options depending on your arrival time.
PLM autocares (
http://plmautocares.com) has a direct bus from the airport to Pamplona six days per week that may (or may not) suit you. If the PLM bus schedule doesn't suit you, Alsa has more frequencies and runs daily from Madrid airport to Pamplona but it means a change of buses along the route (most likely in Soria). Take a look at the web of Alsa
www.alsa.es/en for more info. Once in Pamplona, take a bus to SJPP. Buses from Pamplona to SJPP are operated by Alsa so take a look at their web for info.
If you prefer to make part of the route by train, direct trains from Madrid to Pamplona depart from Puerta de Atocha train station. To get from the airport to that train station, you can take a Cercanías (commuter) train from Terminal 4 in the airport to Atocha or take the Express bus to Atocha from either Terminal 4 or Terminal 1 or Terminal 2. For info about trains,
www.renfe.com and for info about the express bus
www.emtmadrid.es/Aeropuerto (click on English). Once in Pamplona, you would need to go to the bus station to get a bus to SJPP (see above). You can walk it but the bus station isn't close to the train station. If you don't want to walk it, you can either take an urban bus that would leave you close to the bus station or pay for a taxi.
To go from Santiago de Compostela to Porto, the easiest way is to take a direct bus operated by Alsa. You can also make the route by train but you would need to change trains in Vigo. Take a look at the webs of Alsa and RENFE for more info.