If you plan to travel around without fixed dates to move from one location to the next, you can book online for the first location, refundable or non-refundable if you are really sure you want to stay there.
You can next make refundable bookings if traveling in popular times or wait with making a booking if it is almost sure to be possible to book last minute for the next town.
When traveling around, I usually stay in a city or village for two or three nights.
In the past I would call the next youth hostel the night before moving on. These days I use a booking site and book my next place to stay, whether a hostel or a hotel, or an other kind of stay, when I am sure that I will be there or I get a refunable booking when I know I want to travel there but might not be sure about being able to make it.
As a tourist, you can often get good deals in business hotels in the weekends and mostly you will find there is a lot of space, but if you want to go tourist destinations in the weekends in spring, summer and fall, you better book ahead.
While hotels may offer a better deal if you stay more days, often three or seven, it might be cheaper for you to move on and find a new location. So do not just go for the cheaper room, look at the overal costs and whether you want to stay longer in that location.
That being said, take your time traveling.
You will remember more when you travel less, take the odd day to relax and take a break from traveling by spending a few days in a (beach) resort, or go for a hike in the forest.
Again, you can book ahead online but you can also walk in at a travel agency or a tourist information office and get a good deal or good advice from people in the area.
In short, there is no 'best' way of booking for a long travel, as a lot depend on the time of year, the kind of hotels you use, the locations and your personal needs.