Confederate soldiers are American Veterans - they are not traitors, Walt. Read your copy of the US Code, Title 38.
That was not part of the original legislation.
Apparently the law was changed in 1958 to allow the "remaining Confederate Civil War veterans" to claim pensions. Since there couldn't have been much more than
one still alive at that time (if that), the practical effect would have been limited to pensions for any remaining widows and perhaps upkeep on graves. The law was changed as a charitable act of reconciliation, apparently tied to the coming Civil War centennial. The power of Southern Democrats in Congress probably also had a lot to do with it. Title 38 reflects how Americans thought about the war in 1958, but not the situation in 1861-5.