I have used t-Mobile since 2015 on my iPhone. Here, in the Forum, I may be the one who first spread the word about t-Mobile and induced others to switch. I am glad that others have discovered the same economies as I have.
As long as the phone is 'unlocked' and carrier selection is set to automatic in settings/phone it should fire up on a Spanish network as soon as you turn it on after landing. I am not aware of any other special settings that had to be made. But, you can always take it to your local t-Mobile store to verify.
My plan is the "Simple Choice," 5 Gb of data monthly plan. It includes unlimited voice and text in the US, Canada, or Mexico. Overseas, and certainly in France, Portugal or Spain, I use data for mostly everything.
Like 'Trecile' above, voice calls are USD 20 per minute, or about € .16 cents. Unused data rolls over like a downhill snowball, from month-to-month. This feature creates a data 'stash' that I use when volunteering for a month at Santiago each summer. Each year, I return home in late August to a voice-minutes bill of less than USD 10. That is 50 minutes of voice calls, maximum. I do not use the voice capability except for emergencies or managing reservations, and occasionally phoning a friend in Spain.
Personally, and whenever possible, I use my built-in FaceTime app to place audio calls over the data link. If you have FaceTime, look at the top of the screen. You see buttons for Voice or Video. Select VOICE. Also, read this article:
https://www.iphonefaq.org/archives/974213
Hope this helps.