Ghosts are not made up of physical matter - they are pure energy. The spirit will follow the path it did when it was alive - so when there is now a wall where there was once an opening or doorway, that is why folks often see ghosts go through walls. In one bed & breakfast or something of that nature, folks reported seeing the ghosts come down the stairs but they had no feet and ankles. Upon research of the property, the building had been remodeled after a fire, and the new staircase was set several inches higher than the previous one - so they determined the ghosts must have been walking down the old staircase.
Take a look at this video: