Socialism and communism played only a relatively small role in World War I. They were not a part of the cause of the war. They were also not responsible for the end of most of the war. All that these two ideologies did was to hasten the end of one part of the war.
The main impact of socialism and communism was to hasten the end of the war on the Eastern Front. There, Russia was fighting against Germany. Russia was not doing particularly well for most of the war, but it was fighting. This situation came to an end because of socialism and communism. In Russia, socialists and communists helped to overthrow the regime of the Tsar. With the regime overthrown, they continued to protest against the war, which they felt was a war that was only in the interests of the ruling class. Eventually, they overthrew the provisional government that had arisen after the fall of the Tsar and instituted a communist government. This government pulled the country out of the war.
This was the main impact of these ideologies in WWI.
The role of socialism and communism in World War I was limited in that neither of these political systems had actually been implemented in governments of the period and they existed only as movements and ideologies advocated by limited numbers of people. However, there is another way in which we could argue that communism and associated ideologies served as bookends to the war, both involved in the events that precipitated it and helping it draw to a close.
The event that started World War I was the assassination of Archduke Franz Ferdinand of Austria on 28 June 1914, although it can be argued that this exacerbated existing tensions rather than bearing sole responsibility for the war. The assassin was part of Mlada Bosna (Young Bosnia) a revolutionary movement that was a mixture including nationalists and socialists and thus one can argue that the socialists in the group were part of the event that started the war.
The Russian Revolution was in part caused by broad dissatisfaction with World War I. After the Russian Revolution of 1917, Lenin, leader of the new socialist government, negotiated a treaty with Germany and the Central Powers. During 1918, Russia's attention turned inward, and its involvement in the war was limited.