This line from Cole I think summed it up best, "They don't see each other. They only see what they want to see. They don't know they're dead."
And, except for the girl trying to save her sister, I don't know if you could definitively say any of the other ghosts knew they were ghosts. I think the "They only see what they want to see" bit is the key here. In a way the ghosts are making their own reality.
I am from Sri Lanka, and the idea that ghosts are unaware of the fact that they are dead is not totally alien here. I'm pretty sure Shyamalan was aware of these types of myths.
From what I remember from the movie (and other similar movies), it is often stressed that the ghosts the child sees are the soul/spirits of people who have not accepted their death yet, or who still have something to accomplish in this world.
And for Bruce Willis' character, he needed to both accept and understand his death. He could not accept the reality of his death and therefore held on.
Being a ghost in the real world is similar to being in purgatory. You're there until you finish what needs to be finished. Although for ghosts in the real world, it's often more voluntary (spirit chooses to not move on), rather than forced.
I would also add to the answer @Evan give that the basic idea of the ghosts still being around other people (hence "ghost" status/name), is that they are people that did not realized they are dead, and still behave as they normally would.
Another GREAT movie with such example is Passengers (2008) with Anne Hathaway https://www.imdb.com/title/tt0449487 which I suggest everyone to watch; for me was a revelation, and for sure was with much more "soul", "emotions" and "relations" in it than Sixth Sense.