Here, esprit means wit, not spirit or mind. Avoir de l'esprit means being skilled at repartee. In a related meaning, l'esprit de [quelque chose] is a mental attitude that highlights said thing in some fashion, for example un esprit de décision characterises someone who is good (and, especially, quick) at decision-making. L'esprit de l'escalier is a kind of wit that comes when you're in the staircase on your way out from a meeting with someone, and just now realize what you should have said five minutes ago. It's as though the staircase was a necessary factor in your being witty: it is a wit of the staircase. Thus, faire preuve d'esprit de l'escalier means finding the right repartee too late. Avoir l'esprit de l'escalier means doing this habitually.
This expression has a known specific origin: the essay Paradoxe sur le comédien by Denis Diderot, in which the author describes this phenomenon:
This negative remark disconcerted me and reduced me to silence. For the sensible man that I am is fully engrossed in the objection just received and loses his head, to find it only once he has reached the bottom of the staircase.
The phrasing esprit de l'escalier is sometimes attributed to Jean-Jacques Rousseau, but he does not seem to have used the phrase. Indeed that phrase did not come into common use until the late 19th century.