Countries often awarded medals directly to soldiers from other countries when they felt that the soldier or his unit performed some noteworthy service that benefitted the medal awarding country. You did not need to be attached to any units of the country who was doing the awarding. For example, the French "Legion of Honor" medal

was awarded to about 55,000 men during the Great War, of which about 20,000 were awarded to to troops of other countries for having fought in France in their own armies. Then in 1998, France awarded this medal to every soldier from any allied country who had spent any time during the war in France and who was still alive.
Or another example is that in Germany and Austria medals were given sparingly in the early years of the war but as it wore on medals were given more freely not only to soldiers of the awarding country's army but also to soldiers of allied armies, and especially to officers who did not want to be outdone by their comrades in having a chest full.