I can only answer according to the ghost stories I'm familiar with, but with those all the ghosts seen walking through walls were doing so where doors once used to be. Rooms had been remodelled, door-ways moved and the ghosts were just using the route they used in life regardless.
On a side note I've also heard of ghosts walking through floors - for the same reasons. Roman soliders walking on roads several feet below the modern street level - seen from the knees up!
Good question :-)