To get to the point of your question, for the three cities you mention, in Madrid, Atocha station (Puerta de Atocha) serves the South and is the main station in Madrid for the two towns you mention.
Seville and Granada being a bit smaller, you may or may not need to specify a station, but if needed:
For Seville: Seville Santa-Justa has the high speed trains. The station is not centrally located, so you will need to take a bus or taxi closer to the city center.
For Granada, well, I do not recall it being called anything but Granada station. It too is more than walking distance from the center area of interest, again handy buses or taxi to the old quarter.
How soon to buy tickets? You can get cheaper tickets by buying earlier, but really no more than a month or two ahead. The deepest discount is 50% if bought 30 days ahead. Tickets have a "full" price, so they do not go up astronomically near the date, though on peak/off peak pricing is used.
Trains, the high speed ones, are fast, clean, and comfortable. Buses vary a bit by company, but generally are good as well, and needed if you get off the good, but sparse, high speed rail network.
On trains, you will need to go through security, not quite like TSA, but you do need to stand in line, put your bag through an x-ray, and move on. Your Passport number is required to buy tickets. Some report problems purchasing on Renfre, but I do not recall problems using the app.
For Buses, you can buy tickets before getting on at a counter or machine. I found the counter better because in many stations there are a multitude of different windows (and machines) with different companies, but if you make the best guess, if wrong they will point you to the best option for the time of day.