was, oddly enough, a name given to American
soldiers during World War I
. Especially the Americans
The American Expeditionary Forces, sent in 1917, were not exactly "experienced" in the new ways of war, and the stream of raw green recruits sent by Britain to replace the horrendous casualties of trench warfare result in entire regiments full of young, new soldiers that are not accustomed to the ways of war. A doughboy was, hence, a derogatory term for the inexperienced warriors of the trenches.
How this word became the name of a tasty snack, or vice versa, I do not know.