Traveling in September:
What website should I use to buy train tickets from London to Bath?
From London to Edinburgh?
London to Bath Take the bus as low as £1.00 one way depending on the time
https://www.nationalexpress.com/en/destinations/bath/london-to-bath
London to Edinburgh (I flew Easy Jet it was quicker and cheaper than the train at the time I wanted)
https://www.virgintrains.co.uk/train-to/edinburgh
I
NationalRail.co.uk works for all the trains, as far as I know.
Either one of those rail tickets can be quite expensive if not purchased well in advance.
Edinburgh is nearly 400 miles from London, so I'd definitely prefer a train to a bus, and the train will be quite a lot bit faster--4-1/2 to 5-1/2 hours vs. 9-1/2 to 11-1/2 hours. However, the train might also be much, much more costly.
For Bath, I wouldn't mind too much taking a bus if I was making my plans at the last minute. Wouldn't want to do it for a day-trip though, because the extra travel time would really eat into the time available in Bath.
I take it that you do realise that you don’t have to return to London from Bath in order to get to Edinburgh? You generally find trains & fares at www.nationalrail.co.uk - once you have selected a journey, it will send you through to pre-book (for longer trips) with the train company that operates the route. London (Paddington) to Bath is www.gwr.com; London (Kings Cross) to Edinburgh is www.virgintrains.co.uk and Bath to Edinburgh is www.crosscountrytrains.co.uk. HOWEVER, you could book all the journeys with the same operator as they will all sell tickets for each others routes. Cheapest fares appear on system about 11 weeks ahead. Pay on the day for these longer trips can be expensive. Bath to Edinburgh means a short hop to Bristol (Temple Meads) where you change for a train to Scotland. You would probably find it cheaper & quicker to purchase a ticket Bath > Birmingham (New Street) and then from Birmingham to Edinburgh with Virgin Trains west coast service. Another advantage of doing it this way is you travel up to Scotland one way and come back down to London on the eastern route. Most people would break the journey on the eastern route at York and stay overnight.
Route map > http://www.nationalrail.co.uk/static/documents/content/routemaps/nationalrailnetworkmap.pdf
Also consider flying from Bristol to Edinburgh. Find flights at www.skyscanner.net
One exotic UK hobby is trying to assemble the cheapest routes in the tangle of lines and private operators. As always with rail, consult the sage himself, The Man in Seat 61. His strategies would shame a football manager.
www.seat61.com
As others have said, Nationalrail.co.uk is probably the best place for train tickets. You can see what trains are available and prices. When ready to purchase it takes you to the train operator's website for purchase. It couldn't be easier.
You won't be able to buy tickets yet, it's too early, but you can play with routing and perhaps even intermediate stops. You might even consider a "circle" route of London-Bath-Edinburgh-London to save time backtracking. And you would get to see a little more of the English countryside. (I'm a believer that the journey can be as important as the destination.)