I am talking about how this soldiers were motivated to go into that charge, where almost everybody died while trying to get to enemy trenches. Like every soldier in 1916 (just example) had to know that is suicide mission. It was fear of military trials or something else?
Speaking from the British perspective here, 89% of those mobilised came home, with 11% fatal casualties. You're therefore looking at things from a slightly skewed perspective when you say
Like every soldier in 1916 (just example) had to know that is suicide mission.
This simply wasn't the case.
Although some battalions suffered grievously in certain actions (for example the Newfoundlanders on the first day of the Somme), this was by no means unprecedented in the history of war.
Looking at certain actions, we can see that most men could expect to survive.
Vimy Ridge in 1917 saw 170,000 British and Canadians launch a successful attack, sustaining 3,500 dead and 7,000 wounded as casualties. The overall casualty rates are therefore 2% and 4% respectively, with 94% of all men emerging unscathed.
For the first day of the Somme 'the British army's worst day' around 390,000 men would attack for ~19,000 fatal casualties and 38,000 wounded. The overall casualty rates are therefore 5% and 10% respectively, with 85% of all men emerging unscathed.
Accepting here that the casualties would be heavily weighted towards the infantry, and allowing for 16,000 men per division and 14 divisions, that still "only" gives a maximum fatality rate of 8% and a wounded rate of 17%.
These numbers are of course extraordinary, but this was by no means a suicide mission.
By comparison, the French and Coalition forces at Waterloo suffered 33% and 21% casualties respectively.
It was fear of military trials or something else?
It is likely that the threat of a Courts Martial played some role in motivating soldiers to fight but there are no indications that this was a primary motivating factor.
Indeed, of the approximately 8.7 million men who served with the British army at some time in the war, there would only be 3,080 men sentenced to death, and of these only 346 were actually executed.
Of these, 266 were executed for desertion, and only 18 for cowardice. In addition, most of those executed would have had a record of previous bad conduct, indeed several had already been sentenced to death once or even twice before.
This makes it rather unlikely that Courts Martial was seen as a major negative incentive.
In summary, combat in the Great War was not a suicide mission, and men fought and died for the same reasons they fight and die in any war.