I know exactly what you mean and I've thought about it quite hard myself. Not everyone can do this, but as you attune to music more and get used to what a drum kit or guitar playing in a room sounds like, it's easier to pick out the characteristics of live vs. recorded.
I think it's a mixture of things:
The mix- sometimes live music isn't mixed as well as recorded music (e.g. the vocals are too loud/quiet or drums are loud etc). There's seemingly a tendency for guitars to be set more harshly with live music than when recorded.
Reverb: If the band are playing live in say the corner of a pub, all of the instruments will bounce around the room and get much the same reverberaton treatment. In recorded music, different reverb is often artificially applied to vocals vs. guitars / drums etc.
The snare drum especially : You're most likely hearing a snare drum which has echoed around the room before it gets to your ears. In a lot of recorded music, the snare microphone is pretty close to the snare (a few inches) plus some other mikes overhead which are still much closer than the audience would be to the kit. So recorded music tends to have a close-up sound on the snare whereas live music the snare is much more a part of the rest of what's happening. I personally find this a real giveaway.
Vocalists wooping the crowd up between songs (a dead giveaway haha) or little twiddles between songs.
If you're listening to a live album, it still comes across this way because often the reverb from the stadium/hall/room where it was recorded is part of the recording, so the effect is retained.
Having said that, it's possible to be fooled in that "Alive" by Pearl Jam is a live recording but has had a studio treatment afterwards.
Our ears are amazing at picking up signals like this and seemingly we're able to determine live from recorded music quite easily, once we get used to it or train the ear.