First, you must consider the basics. Ghosts are made of ectoplasm.
Ectoplasm carries a negative charge.
That is to say, it contains more negative electrons than positive protons . This results in an unstable body of matter. Ghosts, it seems, do not have trouble being unstable. Their inability to hold on to their electrons explains why sometimes they leave a trail of ectoplasmic residue. Their weak cohesion is what allows them to move through solid objects.