I find the word grammar & its siblings to be somewhat beguiling.
Grammar appeared in English in the late 1300s, meaning the rules of Latin. It came from an Old French word meaning Latin learning. And that Old French word came through Latin from a Greek word meaning the art of letters & learning.
Because the art of letters & learning involved pulling meaning from little marks on paper, & this act was something done only by a small percentage of the population, such pursuits were sometimes seen by the masses as both more-than-human & less-than-wholesome, so the word grammar also meant, magic, spells, & mumbo-jumbo.
By the 1500s, the Latin learning meaning generalized to mean rules of a language to which speakers must conform.
The mumbo-jumbo meaning made its way to become the word gramary, meaning magic, necromancy, or occult learning. When the Scots got hold of this word, it became the word glamour, initially meaning a magical spell or charm, & then morphing in time to mean charming or beautiful, sometimes dependent on artifice.
And in 1849 English adopted the French word grimoire (from that magic, spells, & mumbo-jumbo meaning). A grimoire is a manual for invoking demons & spirits of the dead.
And because all things grammar have to do with writing, the suffix -gram also comes from grammar, giving us telegram, anagram, hologram, mammogram, & a host of others.
Who would’ve thought?