Have you ever wondered what to call someone from a different country? Most nationality words are formed with a portion of the name of the country, with suffixes -an, -ean, -ian, or -ese added, but which goes with which name, and which don't follow any such pattern?
Contrast demonym, the natives or inhabitants of a particular place, with ethnonym, which refers to people of a particular ethnic group. When locations with strong ethnic identity come under one nation's umbrella, using the overall demonym might not be a person's preferred term. For example, the Irish and Scottish residents of the U.K. might not prefer to be called Britons but Irish and Scots.
The first part of the word, dem- (meaning "the people") also forms words such as demographics, and -onym is all about names and words.
Fun Fact: The United States has been accused of appropriating the term American out of conceitedness, but the issue is not so simple. Most countries in North and South America have obvious demonyms—for example, Canadian, Mexican, Honduran, Brazilian, Chilean—but for natives of the United States there is no obvious equivalent that rolls off the tongue. United Statesian doesn’t work. So while the appropriation might be unfair to other people of the Western Hemisphere, it’s also a matter of convenience. Although the use of American to describe U.S. natives may seem illogical, it is widespread and well-established and probably isn’t going to change.
Usage authorities differ on whether it is acceptable use American as an adjective. But, again, it happens, and there’s nothing we can do about it.
Keep in mind, however, while the world describes us as "American" when we meet another American and ask each other where we are from it would be very weird to say "America." So we use the demonyms of the states when speaking with other Americans.
Massachusetts= Massachusettsan or Bay Staters