Edit - I am going to accept any answer between 24 and 26 as correct for this question.
The official correct answer is 25.8 years, but the question didn't specify that players' answer would have to be expressed to tenths of a year. So I will accept 25 (which would be age last birthday) or 26 (which would be age nearest birthday). And since War Horse came up with a source that supports an average age of 24, I will also give credit for that answer.
"All but 1.5 per cent of the enlisted men in the Federal Army were between 18 and 46 at the time of their enlistment; and all but 3.3 per cent of the officers fell into that age bracket. The average age was slightly under 26 years (25.8083) at time of enlistment."
The average Union soldier was 25.8 years old; there is no definite information on the average age of Confederate soldiers, but by the end of the war old men and young boys, who otherwise would have stayed home, were being pressed into service.
I see you've been a member of CivilWarTalk for quite a while, but I'm not sure if you've ever played the trivia game before. If you have not, welcome; if you have, welcome back.
Either way, hope you'll stick around and play again.