Dig in. Earthen fortifications and trenches were the answer.
The old infantry tactics of line and column — standing in the open and trading volleys — stopped making any sense the moment the machine gun arrived. The Industrial Revolution had finally caught up with military technology, and formations that had worked for a century became a way to get men killed in seconds.
So the first tactical response mirrored the response to the first cannons centuries earlier: get below ground level, build earthworks, and make the target disappear. Trench warfare grew directly out of that logic.