From what I have read, the musicians went to war with the regiment. They were formed up behind the company line. They played during Battles. Apparently, at Gettysburg, they played 'Dixie' as Pickett's units went forward - and 'Nearer my God to thee' on the withdrawal. They were for boosting morale. Custer frequently utilized military musicians and bands during his campaigns to boost morale and direct movements during a charge. At the Battle of Brandy Station, he had his mounted musicians loudly play patriotic standards like "Yankee Doodle" to spur his cavalry forward.
There were no Geneva Conventions at this time and no 'Red Cross' so stretcher-bearers had no immunity and casualty evacuation was usually done after ground had been secured - often AFTER the battle. Later, when band became redundant in the field - 1870 onwards - they were used for casualty evacuation.