Trains are rarely full. Buses are not normally full. So I think you can wait until you get there to book. There is a train ticket sales office in T-4 at Barajas Airport. Bus tickets are available from the bus driver, who will have a list of reservations. The bus stop is at T-4. For the train you take the Cercanias from T-4, the price is included in your Renfe ticket, to Chamartin, then catch the train to Burgos Rosa de Lima. Allow an hour to get from baggage pickup to Chamartin.
The bus station in Burgos is downtown, about a five minute walk to the Cathedral. The train station is on the north edge of town, so you will need to catch a 1 Euro bus to Plaza Espana, which is a long five minutes from the Cathedral. The main albergue in Burgos is about the same distance from the bus station and Plaza Espana. Buen camino.