Many of the colonies that became the original 13 United States had their own navies during the Revolutionary War. Indeed, only New Jersey and Delaware did not. Many of those were hastily cobbled together to defend American shores from a superior British fleet. The colonial naval forces were a mixture of formally commissioned ships and privateers that held state letters. These were in addition to the Navy of the United Colonies (the Continental Navy). They fought together valiantly in a number of battles on the seas, rivers and shores along the Atlantic coastline. Most of these makeshift navies faded away soon after the war, although in South Carolina at least the concept returned for an encore during the Civil War. More information on these navies and their heritage can be found on reenactor websites such as the Colonial Navy of Massachusetts, the Pennsylvania State Navy, and the Virginia State Navy.
Today, however, only two states continue to commemorate this rich maritime tradition with their own officially-sanctioned naval ensigns: Massachusetts and Maine.
SOURCE: Wikipedia – Flag of Massachusetts, released to the public domain
The basic design of the Massachusetts flag dates back to the era of the Revolution and features a green pine tree on a white field. The original version also included the motto, "An Appeal to Heaven" but that has since been removed. Officially it’s known as "The Naval and Maritime Flag of the Commonwealth" (recognizing that Massachusetts is but one of four United States that declares itself as a commonwealth).
SOURCE: Wikipedia – Flag of Maine, released to the public domain
The "Merchant and Marine Flag of Maine" is of a much more recent vintage, dating back only to 1939. According to the Maine State Legislature:
The flag to be known as the merchant and marine flag of the State shall be of white, at the top of which in blue letters shall be the motto "Dirigo"; beneath the motto shall be the representation of a pine tree in green color, the trunk of which shall be entwined with the representation of an anchor in blue color; beneath the tree and anchor shall be the name "Maine" in blue color.
It bears a striking resemblance to the Massachusetts naval ensign. I speculate that it somehow relates to Maine having been originally part of Massachusetts until 1820 when it became a separate state. The Latin term Dirigo translates to "I lead" or "I direct" and is the official Maine motto.