It's a bit of a mix. While there are historical events that could potentially be the origin of these ghost stories, a lot of it is likely just legend and superstition. The stories about the old buildings and cemeteries might have started from people's overactive imaginations. However, it's also possible that some strange occurrences were misinterpreted as ghostly activity. For example, old buildings settling can cause noises that people might think are ghosts. But who knows? Maybe there's some truth to some of these stories after all.
Some might be based on real events. For example, the historical tragedies that occurred in St. Augustine could have led to these stories. Deaths, battles, and heartbreaks might have left an imprint that people now interpret as ghosts.
There's no definite proof that they are based on real events. However, the long and often turbulent history of St. Augustine provides fertile ground for such stories. The Castillo de San Marcos, for instance, has seen a lot of bloodshed. It's not unthinkable that the emotional energy from those events could be manifested in some way. But when it comes to seeing ghosts as evidence of real events, it's more likely that the human mind is just trying to make sense of the unknown and the spooky. These stories could also be a way for the local community to preserve and pass on their history in a more interesting and engaging way.