Machine guns were capable of be mounted on cover it could also take down multiply of troops coming out of trenches because of there fire rate and there ammo capacity. it was also useful for suppression begin able to keep down multiple soldiers.
now if you are talking about automatic weapons like assault rifles or sub machine guns then there fire rate would be ideal for close quarters combat or in this case trenches.
hope this helps