The short, "uncomplicated" boilerplate answer? "The Brothers Grimm collected their tales from a variety of sources, mostly middle-class women from a French-influenced background, and then compiled/edited the tales across multiple published editions. Andersen's tales are 'literary' fairy tales, and he wrote them himself." In reality, the answer is just a bit more complicated.
The first thing to note is that there are (generally speaking) two categories of what we would call "fairy tales." A simplified definition of those two categories:
Sidenote: people like Charles Perrault and Madame Marie-Catherine d'Aulnoy fall somewhere in between, as they often 'collected' oral tales and extensively edited/added onto them until they were far more literary in form (or created their own variants on the tales). 1700s French salon culture, which both Perrault and d'Aulnoy participated in, encouraged this practice and it's led to a lot of French influence in the western fairy tale genre. Perrault, of course, has gone down in history as the "father of the French fairy tale," but it was d'Aulnoy that ran one of the most successful and famous salons in France and coined the word "fairy tale" (or 'conte des fées’ in French).
The Brothers Grimm fall into the first category. Hans Christian Andersen falls into the second. What this means, for the purposes of your question, is that Andersen created and wrote the tales he published, while the Brothers Grimm interviewed other people and recorded the tales they were told.
Put another way, "The Little Mermaid" and "The Ugly Duckling" are specific stories that Andersen created & wrote that have a concrete origin and story; there is only one "original" version, and it's the one Andersen wrote. "Aschenputtl" is a specific version of the "Cinderella" story, one of nearly a thousand other versions that were passed down (and changed) via oral storytelling for centuries before the Brothers Grimm wrote it down. There's no "original" version of an oral fairy tale, and there's no single author. There are simply 'earlier' or 'later' (or "more or less popular") versions.
And the brothers were well aware of this! These tales were widely known, told, and circulated at the time; we have records of tale variants of most of the tales the Brothers Grimm collected from all over the world, sometimes several variants from a single location, from different centuries. Cinderella, for example, has over 500 variants in Europe alone! The brothers themselves were heavily influenced by the French versions of several of their tales. Several of the more popular versions of well-known tales (the versions of Cinderella, Red Riding Hood, etc that we think of today when we say "the story of [x]") were actually first widely circulated in Italy, France, and Spain before they ever reached Germany on the same level.
There's some scholarly debate over whether you can consider the Brothers "authors" rather than collectors because of how extensively edited the tales in their collection became by the 7th edition, but ultimately, the Brothers Grimm were scholars and editors of already existing oral stories.
By contrast, Andersen was an author! He was a prolific writer of plays, travelogues, novels, and poems. In his lifetime, his fairy tales were treated with skepticism and a relatively unenthusiastic response by his native Danish audience. Critics largely disliked his style of writing and discouraged him from writing more (something Andersen took to heart so much that there was a hiatus between his second and third tale anthologies). Meanwhile, his travelogues (especially In Sweden) received wide critical acclaim. They're also (mostly) what kept money in his pocket and food on his table during his lifetime. It wasn't until after his death that his fairy tales received a second look and became his lasting legacy.