I think it's proportional to the level of interest you have in the band and music. If you're enthusiatic and like the music, you'll find it a lot easier to learn and remember. By contrast, if your heart's not in it, it goes in one ear and out the other.
I had a similar experience to above, where I was subbing for a friend and had to learn a whole cover set of tunes I had never really heard before in an afternoon. I told him I'd do it so I was determined to get it right. With a couple of cheat sheets I got through the whole thing without any howlers and, at the following gig, was giving the drummer nods where the changes were. At the moment I'm recording an album of tunes I wrote almost twenty years ago but never got to record properly at the time, my brain is well capable of dredging up these riffs I haven't played in so many years. With some interest and focus your brain can do amazing things, it's when you're just going through the motions that you'll find it hard to learn and remember.
An example - in my last band I became quite disillusioned with the nonsense going on and had decided to leave once a run of gig commitments had been fulfilled. We were playing the final of a competition where the prize was a spot at the Wacken festival. Anyway, during one of the tunes I could not for the life of me remember the next riff so I took a guess when the time arrived and f***ed it up spectacularly. That had never happened my before but I had lost interest in the band at that point and I think my brain was just flushing the information down the bog. The worst part was that I wrote the bloody song in the first place