In fact, soldiers on opposing sides in the trenches of the First World War did exchange gifts in the trenches, although this sort of behavior was far from the norm. The most notable incidents of gift exchange occurred during the unofficial Christmas Truce of 1914, although other other instances have been documented by soldiers and historians from the era. While the idea of exchanging gifts with enemies might seem odd to some people in the modern world, at the time, it was viewed as an outgrowth of traditions of chivalry and noble warfare which were still very much alive in Europe.
The First World War marked a radical transition in the nature of warfare, as soldiers began to have access to planes, complex machinery of war, and other tools which created distance between opposing sides on the battlefield. Improvements in battlefield technology also meant that enemies could inflict greater casualties on each other, and that such casualties did not distinguish between soldiers and non-combatants. This caused a great deal of confusion and stress among ordinary soldiers, especially those in the grim environment of the trenches.
Life in the trenches was dismal. Trench warfare involves digging and holding a position, and hoping to eventually overtake the position of the enemy, which is typically a short distance away. If a mission is successful, soldiers from the winning side will occupy the trenches of the other, expanding the territory they control; if not, they will be beaten back to their own trenches, often leaving dead and wounded soldiers and a plethora of equipment on no man's land, the stretch of land between enemy trenches. Given the conditions, you might see why soldiers chose to exchange gifts while in the trenches, recognizing their common misery.
When soldiers did exchange gifts in the trenches, they were typically lower-level enlisted men. Some soldiers occasionally threw gifts of food, drink, and other presents into the trenches of their enemies during the war, sometimes with friendly notes. The idea behind such exchanges was far from diplomatic; soldiers probably wanted to reach out to each other because they saw that they had a lot in common. As one might imagine, high command frowned severely on such exchanges, but they were powerless to stop even such events as period gift exchanges and musical performances put on for the benefit of the enemy.
The most notable example of soldiers who did exchange gifts in the trenches occurred in 1914, when German and English soldiers declared an unofficial truce on Christmas Eve. Initially, the Christmas Truce was used to transport and bury the dead, with the understanding that neither side would fire on the other. However, soldiers also started exchanging presents like alcohol and Christmas cakes, holding up signs with seasonal greetings and singing Christmas carols and even erecting a Christmas tree in no man's land in one case. In a few areas, the opposing sides actually met to play games together, socialize, or sing in groups.
The Christmas Truce lasted into January in some regions, during which soldiers did exchange gifts in the trenches on a regular basis, despite pleas from high command to stop. This little-known event of the First World War is often a source of surprise, confusion, and delight to people when they first learn about it.