There are regular buses throughout the day between Madrid and Bilbao. The journey takes five hours. The train journey is of a similar length but more expensive (and less frequent), but the train station in Bilbao is more central than the bus station, making your transfers a whole lot easier.
You can book most bus tickets in Spain online at no extra charge. Just pay with a credit card and print out the e-ticket.
There are two trains a day from Bilbao to Madrid, taking five hours. The bus is cheaper but a little less convenient. Trains from Madrid to Bilbao depart from Chamartin train station.
It takes 4 hours to drive the 400km from Madrid to Bilbao, following the A-1, AP-1 and AP-68 Note that AP roads in Spain are toll roads.
Consider a stop in Burgos to break up the long journey.
There are regular flights from Madrid to Bilbao and they can be very cheap if booked in advance.