There is a subway between Madrid Barajas Adolfo Suarez airport and Madrid, although the rates have risen and now for large groups it is cheaper to rent a shuttle service to the airport than going with the subway.
When you take the underground to go to Madrid Barajas airport, note that you must purchase a special ticket, otherwise you will not be able to exit the subway station at Barajas Airport, whether it's at the metro station terminal 1-2-3 or if you need to go to the last metro station at T4 terminal. In addition, other disadvantages may be transporting luggage in the absence of escalators or elevators, or the journey.
Single Ticket Metro Area A + Supplement Airport 4.50 to 5 €
You wouldn't really ever recommend buying a ticket to enter the metro just to get from T1 to T4. It would cost 4.5-5eur because you pass through all the check points. Maybe even more, because you pass through two airport check points, going into the metro then out of it, both times in the aiport.
Another alternative is transport by collective transfer, there are companies that offer shuttle service shared by a lower price.