Unfortunately Castro Urdiales does not have an airport. Nevertheless it is easy to reach by bus from Santander or Bilbao, which are the nearest airports. And obviously from Madrid.
Castro-Urdiales is located in the coast of Cantabria. However, it is very close to Bilbao, about 35 km, where there is an international airport (Sondika Airport). At the airport, you can take a taxi to get Castro-Urdiales, this is the easiest way. The taxi costs approximately 45 euros and the trip takes around 25 minutes. However, the cheapest option is to go to bus station of Bilbao by bus from the airport (the journey time is around 45 minutes and the current cost is €1.15, see this timetable) to Termibus (Bilbao bus station) and then to take a bus to Castro Urdiales (there are many buses connecting Castro Urdiales and Bilbao, see), that is:
Bilbao airport---> bus station of Bilbao (Termibus)---> Castro Urdiales
In Santander there is also an international airport, Parayas Airport, and so you can take a flight to Santander and then go to Castro Urdiales (about 66 km). At the airport, you can take a taxi to get Castro-Urdiales, this is the easiest way too. It costs approximately 60 euros and takes around 50 minutes. However, the cheapest option is to go to bus station of Santander by bus from the airtport. The Santander airport bus stop is just outside the main terminal building and the buses run into Santander every 30 minutes from 06:30 - 22:45. The airport is only 5 kms from Santander so the journey is quick and costs just €1.50. Then to take a bus to Castro Urdiales (there are many buses connecting Santander - Castro Urdiales (round trip price about 10 euros), see), that is:
Santander airport ---> bus station of Santander---> Castro Urdiales
Madrid is about 427 km to Castro Urdiales. You
can choice to go to Madrid airpot, Barajas Airport, take the underground
to Méndez Álvaro stop, and then take the bus to Bilbao (see
timetable) and finally from Bilbao to Castro Urdiales by bus.