Sevilla is wonderful and it's very easy to get there via one of the high speed trains. It is possible to purchase tickets once you're in Madrid, but there are a few reasons you may want to buy them in advance.
One, you will often find really good deals on the RENFE website; depending on availability, you can find "estrella" and "web" specials. Two, you will have confirmed seats so you won't end up disappointed if you aren't able to buy tickets once you're there. With all the Iceland volcano activity, the airports have been closing intermittently around Spain for the past few weeks, so airline travel isn't very reliable right now. If you were to drive, it would take you at least five and a half hours.
Be aware that occasionally people have difficulty buying tickets online. For one recent discussion, see
here. It seems that persistence is the best solution for purchasing RENFE tickets online; in other words, just keep trying.
Good luck and have a great trip!