My experience is that they were buried close to where they fell if in battle.
There was a Confederate camp in the county I live in.
Those poor men died of disease and there was nothing to do for them at the time, except bury them. The thought at that time was to get them in the ground, the quicker the better, if they died with some disease.
As far as being at the cemetery, he may have had the good fortune to have been put in one, but the grave went unmarked even though he was Union.
It is also possible that some good person in the area buried the man rather than leave his body out. I would suggest you read the old papers from the time and the area the men served within.
Supposedly, two Union soldiers were buried in the area where I live. The folks who helped them could not tell the Confederates that they had cared for the soldiers until they died. They also could not tell the Union for fear of being accussed of killing the men. Supposedly the men were buried with their uniforms, guns, etc. in the edge of a field near a body of water.
If I know of one story, there were surely more.