We're not really told why Kwan-Si first changes their walls into the shape of a pig, but the messenger bringing the news seems to think that by doing so, they have made themselves the more powerful town. A pig will eat an orange, and so it looks like they are the town of strength. So, the Mandarin immediately orders the shape of the walls changed to look like a club, to beat the pig away. The towns prolong this competition because the town with the "strongest" wall shape would be the winner, and therefore the more prosperous and successful town. Think of it as a giant game of "Rock, Paper, Scissors".
Because of this competition, the townspeople have no time to tend crops or run businesses; instead they are constantly building and rebuilding the walls. So, they fall ill, lose money, and begin dying. Even the Mandarins are sick and weak at the end of the battle. Because of their greed, and refusal to work in cooperation rather than competition, their towns have suffered greatly.