Nicholas B. answered 09/06/21
Passionate about technology and history!
Despite the racism and attitudes towards African Americans in the late 18th century, it was not necessarily believed by citizens in the North that black Americans were automatically seen as slaves. Rather, it's more important to view them as second class citizens who were very likely to be enslaved in the South and experience systemic racism and Jim Crow-like abuse in the North.
Many African Americans were welcomed, as your question asks, into the ranks of local militias as a result of needs during the war. Enlistment quotas were not being met, and through using this "untapped" source, they were able to meet these quotas against the British. As many as 5-8,000 African Americans joined the American cause, usually as a result of promises of freedom in the case of some enslaved peoples.
Despite these attitudes and the recruitment of many African Americans, there was fear among Northerners and Southerners alike of a slave rebellion. The fear that was instilled in slaveholders and white Americans alike was very real, as slave rebellions had occurred in the New World at this point. As a result, rather than participate in the stereotypical musket-wielding fashion that we tend to associate with soldiers of the American Revolutionary War, many (not all) were removed altogether from being able to wield weapons and were resorted to support roles. This is according to the Jamestown Settlement & American Revolution Museum at Yorktown, an accredited institution by the American Alliance of Museums:
Most black soldiers were scattered throughout the Continental Army in integrated infantry regiments, where they were often assigned to support roles as wagoners, cooks, waiters or artisans.
Furthermore, your question asks why the attitudes towards allowing black Americans into the ranks of the Revolutionary Army changed. I would actually argue on the contrary. Much like modern America, it's difficult to describe the attitudes of an entire country as one congruent policy. As stated before, many enslaved peoples were promised freedom in exchange for fighting for the Americans. However, the South was vehemently against this. While they had no problems recruiting freemen, the prospect of giving freedom to slaves was scary to white Americans and implicated not just the slaveholders in the South, but also Northerners, yeomans in the South, and others.
I hope this was able to answer your question.