The 13th U.S. Infantry regiment was stationed at Fort Porter from the mid-1840's through 1926. It was called "Buffalo's own" regiment because of its long association with the city.
In the scene above, the gunners in the foreground are ready to fire a piece of field artillery. The wagon and soldiers located a safe distance to the rear are soldiers responsible for the caisson (or limber) which carried spare ammunition. The crew of 4 soldiers standing at right are "replacements" for gunners who may be wounded or killed during action.
In 1926 Fort Porter was closed as a military reservation and the barracks demolished as part of the construction of the Peace Bridge. (The City of Buffalo acquired other parts of the fort's acreage, moving the fort's "Castle" there, until the 1953 expansion of the Peace Bridge approach facilities absorbed the remaining land and the old stone building was demolished.)
Read about the Fort Porter Castle here.