In Spain your train ticket will automatically come with a seat reservation if the train you're taking requires reserved seats. There's no way to reserve a seat on the comparatively slower, local trains.
Tickets on the reserved-seat trains are often a lot less expensive if you buy them early, but that's risky if your plans aren't rock-solid.
On some trains you have the option of paying a bit more and buying an Elige ticket that allows a change or partial refund. Some of the very fast mainline trains (especially segments running between Barcelona-Zaragoza-Madrid-Cordoba-Seville) sell out fairly often. It isn't necessarily safe to wait until you are ready to travel to buy those express-train tickets. At the least, you should keep an eye on renfe.com to be sure trains aren't beginning to show up as "Full".
Renfe is the largest operator of trains in Spain, but there are others. It won't hurt to check TheTrainline to see whether there's a useful train being run by a different company. You should buy your ticket from the operating company if possible.
It's my impression bus tickets don't go on sale as far ahead as train tickets. Although the fares don't seem to vary as much as rail fares, I think you can often save money by buying your bus ticket ahead of time. I had one experience of finding the bus I wanted to take already sold out when I arrived at my transfer point and tried to buy a ticket. I have no idea how frequently bus sellouts occur.