The machine gun was invented 1884 that's the first time they used them. Machine guns were effective in WWI because they helped change the military moving the armies away from massed formations and into looser battle order. The main advantages were that it was cheap and effective in trenches and could wipe out a lot of soldiers within a short period of time.
Trench warfare was invented September 1914. Trenches were made for the soldiers to be protected by machine guns. Trenches were long narrow ditches dug into the ground where soldiers lived in WWI. They were very muddy, uncomfortable and the toilets were dug into the ground.