In this video, Fr. Mike Schmitz gives a Catholic perspective on ghosts.
Yes, Catholics can believe that ghosts could exist, but we should not attempt to communicate with them. And there is a difference between ghosts and demons. Demons are fallen angels.
Why would God allow ghosts to manifest themselves to us? Fr. Mike believes that ghosts are actually the poor souls in purgatory. They are trying to get our attention so we will pray for them.
And he shares an interesting story about a ghostly manifestation at a convent and how praying for the soul ended it.