Flights all arrive at Adolfo Suárez Madrid Barajas Airport which is very well connected to the city. Easily reach the center via train or metro without needing to shell out for a taxi.
Spain is also very well connected via Renfe – the national rail system – as well as having plenty of bus routes. Check Flixbus and Alsa for bus timetables and prices. You can also buy on Omio which lays out all the options for you, however, I didn’t find they always had each option.
BlaBlaCar, a rideshare app is also very widely used and a great budget option.
3 – 4 days for the city and a few more for day trips
You are essentially right in the middle of Spain. Barcelona and Valencia are east along the coast (slightly north and south, respectively). There is plenty to do up north with Bilbao and San Sebastian or head down to Andalucía where you’ll find Seville, Granada and Málaga.
For more general information on visiting Spain such as Covid updates, visas and more you can check out the Spain travel page.