What problems did trenches cause for the soldiers?
I would concentrate mainly on trenches during WWI:
Trenches are a form of protection/fortification for the soldiers allowing them to get shelter from shells, bullets, splinters and, basically, enemy fire.
On the other hand if you are the one attacking a trench, as in WWI, probably you'll have a bad day!
The same characteristic that makes a trench a very useful protective structure makes it a very dangerous and potentially deadly enemy emplacement.
First of all a trench has firing positions where soldiers use the protection offered by the trench to fire to incoming attackers (normally using a machinegun!);
Then the trench is built to withstand shelling so that soldiers are protected during the enemy opening artillery attack and come out when the infantry attack starts;
Finally the trench is cleverly built to produce as much damage as possible to the attacker: it comprises barbed wire "fences" to force the attacker to stop and get more vulnerable; minefields with paths through them to "channel" the attackers into killing zones (paths leading to machineguns); their geometry tends to separate the waves of attackers in chunks and to disorientate the soldiers to be easily eliminated by the defenders.
There is also a specific set of problems for the soldiers actually using the trenches for defense and mainly related to sanitation hazards: the trench, in particular during WWI, was not a very clean or healthy environment.
1) Dampness and cold: causing diseases and damaging the skin/limbs (trench-foot);
2) Parasites and vermin: the trenches are perfect environments for rats, lice, fleas and all the other infesting insects present in a dirty environment where (not washed) people have to live in close contact;
3) Bodily fluids. Evacuation of human feces is problematic as it is for the bodies of dead soldiers and shelling, for example, can disperse them or even rotting flesh on soldiers causing diseases.
These are only some of the dangerous characteristics of trenches that an attacking or defending soldier had to face.