I have done this twice LHR - MAD - Almeria & it has worked fine but I would be panicking if I had less than an hour betwen flights.
Travelling from London, we left from the same terminal that we arrived in but the terminal is huge & by the law of sod, we arrived at one end & departed from the other. It was a good 15 minute walk.
Doing the journey in reverse, we had to use a shuttle train to get from one terminal to another & again, this took quite a while.
Friends of mine did this return journey last Summer & even with the same carrier, they did not get their flight at Madrid due to delays departing from Almeria & they had to stay overnight.
Personally, I always leave loads of time & I would definitely want at least a 2 hour stopover.