Cercanias is the commuter train system. If your train ticket from Chamartin to Leon is on a high speed train your connecting Cercanias ticket is included in the price.
There is a QR code in the corner of your ticket or if using the tickets on your phone there will be a similar code. At the T4 stationbottom level there will be a number of C train turnstiles and one will have an electronic code reader. At T4 there are usually attendants in yellow/orange vests who can help you. Show them your ticket and they can point it out. Once you have done it, it will be clear on the future. You scan the code and the turnstile will open for you.
If you don't have a high speed train ticket. There is a machine to buy a Cercanias ticket from the airport directly to Chamartin. Take train C1 or C10 they are the only ones that come to the airport and both stop at Chamartin and also Atocha stations.
You must buy the tarjeta dorada on person. There is a train ticket window on the same level in T4. You can buy one there or any train station, but I would not wait to buy a train ticket until you have one. Tickets can sell out and the further in advance you buy the cheaper they are.
I bought my first tarjeta when I turned 60 and then renewed it for 3 years when I was 61 since we return to Spain every year. My trainline App saves the data and I can buy my tickets online with the discount in advance now. I use the Trainline app to look up schedules and buy tickets. It is in English and accepts my US credit card.