Looking on Wikipedia at some WW1 battles, and under the German Empire it noted the separate flags of Saxony, Bavaria and Prussia. Did these states have separate armies? How much autonomy did they have under the German Empire?
Depended on the state. The four kingdoms - Prussia, Saxony, Württemberg and Bavaria - maintained a certain independence from each other, with separate war ministries and so on, but integrated uniforms and weaponry for practical reasons. The smaller states' armies were essentially subsumed into the Prussian army following the formation of the Empire, but they remained tied to a particular region and wore identifying marks - for example, on the soft cap there were two cockades: a black/white/red one for Germany and another below for the individual state. In this picture, the second cockade is white/red/white for Hessen.
I've read numerous British war diaries and the like where officers say things like "the Hessians opposite have moved out and been replaced by the Mecklenburgers who are a much nicer bunch", so even during the war the different regiments were maintaining some of that distinctiveness.
Sources; on uniforms, Philip J Haythornthwaite: The World War One Source Book.
I don't recall the exact location of sources on the war diary, but almost certainly Richard Holmes's Tommy.