If Dorothy and her companions had not been captured by the Wicked Witch of the West, they would not have been able to kill her. The Wicked Witch of the West is the one who brought Dorothy and her companions closer to her.
Dorothy was supposed to kill the Wicked Witch of the West but it was a long journey. The Wicked Witch of the West sent her supporters to capture Dorothy and her companions. Then Dorothy threw a bucket of water on the witch and thus killed her.