Can I buy ticket on the day of travel, or is it best to buy in advance, with a flexible time? And is LNER the website from which to purchase train ticket, Edinburgh to York, June 21, and then York to Kings Cross June 23?
Yes you can, but you can get much cheaper prices if you book ahead.
I can see an Advance single from Edinburgh to York at 8am on 21/7 for £29.20 - the walk up price will be £63.80.
For 23/7 there are Advance fares from £35.80 from York to King's Cross that morning. The super off peak fare is £75 and the Anytime fare (before 9.30am) is £118.40.
But the Advance fares fix you to a specific departure. If you want to be flexible you will need the £63.80 and £75 fares, which you can buy on the day.
I'm just back from the area. Took your trains and a number of others near York, Durham, and Edinburgh. I found the LNER app worked very well for me - both from the US and when in the UK.
As noted above, I bought the distance trains in advance before leaving the US - big savings.
You can almost always buy last minute Advance (train specific) tickets up until minutes before departure. It is extremely unlikely that you would ever have to pay the full flexible fares quoted.
The Scotrail website/app is the one to get the best last minute fares. Cross Country trains and Transpennine also run from Edinburgh to York- the latter with a change at Newcastle. Transpennine often have the best fares.