In one sense, it's impossible to know why Luigi Pirandello uses so much dialogue in his short story "War." We don't actually have an essay by him explaining his choices, and we can't read his mind.
One possible answer is that he was a playwright as well as novelist and he was interested in the possibilities of dialogue. Another possibility, which seems probable in light of his play Six Characters in Search of an Author, is that he preferred to let characters speak for themselves rather than mediating our experience of them through a narrator.
One reason the story demands to be written as dialogue is that the substance of the story is as much about the nature of conversation as it is about "war." The situation of the story, with the characters trapped in a train car, means that they cannot do much but talk, and the war both brings them together through their shared conversation and pushes them apart in the way that it almost becomes a competition in suffering. Dialogue seems the most appropriate way to convey this.