If the info on the web of Autobuses Amaya is updated (i.e.: if they keep having the
early morning Saturday bus from Castrojeriz to Burgos as they had last year), I would consider the option of stopping walking in Castrojeriz and taking that Saturday morning bus to Burgos (note for other people reading this post: the Saturday bus is seasonal and ends on Sept. 30th). Once in Burgos, there are plenty of buses and trains to Madrid and you shouldn't have problems to find one.
Autobuses Amaya schedule from Castrojeriz to Burgos:
http://autobusesamaya.com/las-rutas/castrojeriz If you want to confirm the schedule directly with them, take a look at
http://autobusesamaya.com/donde-estamos for email and phone contacts.
For buses from Burgos to Madrid, take a look at the web of Alsa:
www.alsa.es/en
For trains from Burgos to Madrid, take a look at the web of RENFE:
www.renfe.com
I would disregard the option of going via Frómista because I'm not fully sure if it would work on the OP travel date and, even if it worked, it would be a bigger nightmare. Firstly you would need to reach Frómista from Itero de la Vega (walking, taxi...). Once in Frómista, there aren't trains out of Frómista on your travel date (see below). It might be buses from Frómista to Palencia but the web of Linecar (the bus company making the route from Frómista to Palencia) is so poor that doesn't offer schedule info about all their routes but just about some of them and, sadly, the route from Frómista to Palencia is one of the routes without online schedule on their web. You might ask someone if they can call Linecar (or call yourself if your Spanish is good enough) and ask about Saturday's schedule out of Frómista (to Palencia) to know if they have buses running on Saturdays (or if they don't have them) and, if they had them, whether their schedule suits you (or not).
www.linecar.es (click on Oficinas y Estaciones on the left menu to get their number in Palencia). Don't forget to check the arrival time to Palencia because the last bus from Palencia to Madrid departs at 19:30. Take a look at the web of Alsa for buses from Palencia to Madrid. Train would be another option from Palencia to Madrid but due to the works I quote later, most trains involve a change to a bus during part of the route (returning to the train later) so bus would be a better option (less hassle) on your travel date (and the last train departs earlier than the last bus to Madrid)... although, as I said above, I would disregard the option of going via Frómista if the Saturday bus from Castrojeriz to Burgos is running on your travel date.
There are trains from Fromista, but there is no service on Saturday and Sunday.
There's service on Saturdays and Sundays. The problem is that there isn't service on the specific Saturday the OP is travelling due to engineering works on the tracks near Valladolid. But if anyone else is reading the thread and needs a Saturday train out of Frómista, it should be one (well, in fact, two)... unless you happen to need to travel on a strike day or, as the OP, on a day where engineering works are being made on the tracks.