A soldier's remains being recovered and brought home is really not that unusual. Depending on who controlled the rail road at the time, soldiers were brought from the battlefield and placed in hospitals along the way. If the man died at the hospital, he may have been buried and later sent home or sent home immediately if family members knew his location and could make arrangements.
I am most interested as to why he could not be buried in a church cemetery "because he was a mason." Since freemasonry was well received throughout the country at the time, my only guess why he could not be buried in a church cemetery is that he was not a faithful member of the church. I may be wrong, but Catholics who joined the Masons were excommunicated because freemasonry was a secret society and was predominantly made up of members of the mainstream Protestant faiths and made denunciations against the church in Rome.
There may have been other religious groups who also opposed masonry, but I do not know on what grounds.
I can't think of another reason why he could not be buried unless he had committed some other major infraction of church laws or local mores. I have heard of men being buried separately because they had gone to the enemy, but not for membership in any particular organization.