Thank you for posting your request on History Hub.
In regards to Maryland, recall that Maryland, although a slave state, did not secede from the Union, and more of its men served for the Union than, in most cases, traveled across the Potomac River into Virginia to join the Confederate forces. In most general terms, the deciding factor often seemed to be whether the soldier supported slavery or was against it. However, it is not really possibly to determine why he might have chosen to serve in the Union. He may have had convictions which predisposed him to serving in the Union, or he may simply have seen it as an opportunity for income. The reason for serve is not recorded in the service record. You may wish to research inline, especially looking at the area in which he lived. There may exist historical societies which could assist you in learning more about the particular ideas and feelings of the general population of the time.
I have located a useful list for genealogy research which you might find helpful in researching the gentleman himself.
Maryland in the Civil War
I hope this is helpful in your research!