Hi, Meg,
Falcon has posted the bus schedule, and you'll see that one leaves from T4 at 7:45 a.m. (that's the airport terminal 4, where you will land if you arrive on Iberia or one of their partners, like American). If you arrive at another airport terminal, you'll need to take a bus to get to T4, so it's a bit more complicated. But my guess is that your flight won't arrive in time for you to clear customs and make a 7;45 am bus.
The RENFE site shows two trains a day, one at 8 am, one at 4 pm (both about 6 hours). The train station is a quick ride on the C1 cercanias train line, less than 15 minutes, also leaving from T4.
What time does your plane arrive in Madrid?
I'm assuming you will be walking the Camino del Norte if you're headed for Irun. When I walked a few years ago, I just took a bus straight from T4 into the Av. de Americas bus station, easily bought a ticket on the next bus to Bilbao, and spent a day getting over jet lag in Bilbao. I knew I'd be walking back through the city on the Norte, but I thought that would be too early in the walk to take a rest day, so I decided to see the sights before I started walking. From Bilbao to Irun is a very easy bus ride, there are frequent buses, and the bus station in Bilbao is well connected to downtown Bilbao by the light rail train that runs right by the Guggenheim and then heads into old Bilbao.
Buen camino, you don't have too much longer to wait. Laurie