Upvote:5
On the first day, your flight from Spain should land in the Schengen area of the terminal and you should simply walk out of the airport without any passport check. That ought to be true in any Schengen airport, in Germany and elsewhere. If for some reason (unusual airport layout or operational issues) you do end up in a non-Schengen terminal, you might have to cross a check point but still shouldn't get a stamp (it has happened to me a couple of times on departure).
You would then go through passport control when leaving the Schengen area. Leaving the airport or how long you spend in Frankfurt shouldn't play a role at all and you should be treated the same whether you come straight from a Schengen flight or from outside the airport.
Whether that means you will get a stamp depends on the type of residence permit you have and how thorough border guards are. Most third country nationals residing in the EU should get stamps but some don't (e.g. family members of EU citizens) and some countries do not apply that rule consistently or even systematically omit to stamp passports for all residents. If you know for a fact that you wouldn't get a stamp if you did not leave the airport then it should be the same when coming from your hotel.