Madrid underground network is directly reachable from the airport, and this is the best option to move from there to the train or bus stations. A third possibility is to fly to Sevilla. Sevilla airport does not receive so many internacional flights, but this may be an interesting option for visitors from certain countries. There are also other kinds of trains available. Before buying your train tickets, you may want to have a look to the timetables.
Fares can also vary depending on the date and time.
Don't forget to specify if you want a smoker or non-smoker ticket.