One theory that's popular: there are various bodies that make up a being. Physical, astral, mental, etc. There's disagreement on the particulars and I'm certainly no expert, it seems to be that the astral body (one 'layer' up from the physical) is gradually discarded after death; it wears out like the physical body after a while, and drifts around, an empty husk.
Without a 'soul' to animate the astral body–and especially if someone died a horrible death, or had unresolved emotions that were very strong, or something of the sort–the astral husk gets stuck in a kind of loop, like muscle memory, repeating itself over and over. Ever heard of those ghost stories of hitch hikers, always doing the same thing and disappearing spookily by the end? Over time the brain and body grow accustomed to doing things a certain way, like digging a rut in the soil over time as you walk the same path: the grass becomes dirt, becomes a trail, becomes a path, becomes a road, until it's used so much that people decide to lay down bricks and make it a proper thoroughfare. I imagine this is how the mind works, especially when energized by strong emotion. Heavy guilt, unrequited love, especially over years, has potential to animate these astral bodies, whether or not the 'soul' is still inhabiting them.
This is just one theory, of course.
Dinosaur ghosts aren't around because, just like physical bodies, astral bodies decay too.