I think in the case of Atocha, I'd like to be there 30-45 minutes before the train leaves.
That is a wise decision. The responses that say "hey a few minutes is more than enough" are not helpful and it appears they were speaking of other countries, not Spain.
First, if you are arriving at a strange station, it will take you a few minutes just to figure out the layout, figure out what track you need to be on, and in some stations, that can be a hike to the track, and then to your car.
Second, speaking to Atocha specifically, once you get to the "fast train" area, you will first be stuck at a central security point, like an airport, not as bad, but there will be a line, it will be for all fast trains, and is a delay. Once you get past that, you go into a waiting area, there are a few snack places and a restaurant or two, but much better variety is before security. The track typically is not announced until just before departure (5-10 minutes?) but the regular riders seem to know the track used.
I would agree, Granada and Malaga are much smaller stations, 20 minutes or so should cover most issues encountered. I usually get there a little earlier, grab a coffee, and figure things out.