Be careful, buying your ticket for each leg at a time can be risky because Indian trains fill up very quickly, and you might end up without a seat if you book too late. If your itinerary is fixed, you can purchase all your tickets at once at the first station where you book. Otherwise, you can fall back on private buses, which can be booked the day before, or public buses (no reservation required) when possible.
Even in the past, you always had to book well in advance, but since Indians have started traveling for leisure, it’s become even worse. I’ve been on the WL (waiting list for those who don’t speak English) more than a month in advance...
As you said, you need to book your tickets as soon as you’re sure of the dates, trains, and the class you want to travel in. Tickets are refundable for a small commission, which isn’t too bad. There’s even insurance at a minimal cost that allows for a full refund.
I book all my tickets quickly using the (Indian) ixigo app.
Traveling by train has become quite complicated if you leave it to the last minute. Unless you travel in General class without a reservation, at your own risk, to find a seat.
Je rencontrai sur mon chemin tant de difficultés
Qu’elles furent toutes surmontées
MIRZA GHALIB poète urdu (1796 -1869)
https://www.telling-india-pictures.com
https://youpic.com/marien