How do the moving walls relate to the theme?
I guess a lot depends on what you consider the theme of "The Pit and the Pendulum." There are a few that are present in the story. Fear, isolation, torture, death, will to live, etc. are all identifiable themes in the novel. The themes I just listed though aren't that different from each other. They all fit together. If I was being held in isolation and being tortured, I would most definitely be afraid and wonder exactly how much will to live I could muster.
The moving walls is just another progression in the hell that is the protagonist's life in the story. His fears about death begin with a crazy thirst, then are enhanced when he learns there is a giant pit of death in his room. Then comes the pendulum of death ready to slice him in half. He survives all of it. Then the walls begin closing in on him. Jump in the pit? Get crushed to death? Keep fighting? Those questions are great for this story, because I think it was a main focus of Poe's. I'm not sure if "what would I do?" is a theme, but it's definitely present throughout the story. The walls relate to that feeling and all of the other themes. They are the penultimate challenge, torture, fear device, killing machine, etc.
On a side note, I've always been disappointed that the main character got rescued. I didn't want him to die. I wanted him to figure out a way to get out of the situation. He was able to do it for all of the others, so I felt robbed of that possibility when a miraculous rescuer showed up.