In a language, grammar is the way words and sentences are assembled to create meaning. Grammar is often synonymous with syntax and deals with how we structure sentences. Grammar includes rules about the building blocks of sentences, such as phrases, clauses, and parts of speech. The parts of speech are nouns, verbs, pronouns, adjectives, adverbs, prepositions, conjunctions, and interjections. (For a quick review of the parts of speech, check out the Schoolhouse Rock videos on YouTube.)
Each language has its own grammar that defines where subjects, verbs, objects, and other items go in a sentence. In English, the structure tends to be subject, verb, object; adjectives go in front of the nouns they describe. An example of a grammar mistake is "Ethan and Dan walks to the library." Today we use the word "grammar" to encompass all kinds of mistakes, but the definition of a true grammar mistake should be narrower.
Usage, as the name implies, governs how people use the language. These guidelines are a consensus of the clearest way to communicate in writing. Like fashion and other trends, usage changes over time. For example, the spelling of compound words falls under usage because the spelling varies between dictionaries and decades. Another example is whether a noun like "staff" is considered singular or plural. (The staff goes to a meeting vs. the staff go to a meeting.)
Mechanics, another term I stumbled across, covers rules related to spelling, capitalization, and numerals. To my mind, punctuation also falls under mechanics since it lays out how to use the marks that help readers hear and understand the sentence the way the writer meant.
Style is a set of agreed-upon preferences. For example, there is no grammatical rule that prohibits us from starting a sentence with a conjunction or ending it with a preposition. Like usage, style changes over time.
Does any of this matter? I see two reasons for understanding the differences. First, knowing the terms helps you to phrase questions to find the answers. Second, you can prioritize comments you receive about your writing. If there are true grammar mistakes or errors in mechanics, then fix them. On the other hand, if the criticisms relate more to usage and style, then you have more leeway in deciding how or whether to change them.