The reason it has a tail is because micrometeoroids bombard the planet surface and knock tiny pieces of it into space. Those pieces contain mineral-building atoms like sodium—which, when hit by sunlight, glow.
So what you're seeing is a thin, glowing trail of pieces of Mercury.