Jacob and Wilhelm Grimm (1785-1863 and 1786-1859, respectively) published their first volume of Kinder und Hausmärchen (Children’s and House Folktales) in 1812 and their Deutsche Sagen (Teutonic Legend) from 1816 to 1818. A series of books written independently by Jacob Grimm earned him the title of the father of folklore science.
The brothers actively collected folklore, and that was the basis for their collection of folktales. Their first edition included material from previously-published folktale collections - a few from the French, but these were weeded out in later editions. They "abridged" the lengthy stories they heard, making them shorter and toning down the violence and sexuality, but their collection was based on the material they collected - so that's the answer to your first question.
To your second question: they were very much "self aware" that they were preserving German heritage - in fact, that was largely their inspiration. Germany was a collection of independent states and was the home of a language and culture that had been under assault during the Napoleonic War. They hoped that their work would preserve an aspect of German culture that was fading with modernization, urbanization, industrialization, and the growing international character of Europe. They hoped to promote all things German and to contribute to an effort to inspire respect for the core of German culture.
edited to change 'first addition' to the intended 'first edition'
In addition to the already excellent response here, I would add that specifically, while many of their tales were actually collected from the peasantry, quite a few of their tales were collected from middle-class or aristocratic acquaintances, especially those with a middle-class French Heugonot background via August von Haxthausen and his circle of friends, Dorothea Viehmann, Marie Hassenpflug, and Wilhelm’s wife Dorothea "Dortchen" Wild.
The Brothers Grimm were extremely self-aware that they were preserving heritage, as /u/itsallfolklore stated and expounded upon quite nicely. In fact, that's a large part of the reason they started collecting the tales in the first place! Many fairy tale and folklore collectors beginning in the 1700s often collected and edited their stories with explicitly nationalist intentions (though that was certainly not their only intention by any means), largely influenced by the work of philosopher Johann Herder. The rise of romantic nationalism was explicitly intertwined with the collection and dissemination of fairy tales and folklore and influenced collectors from the Brothers Grimm to Asbjørnsen and Moe to Joseph Jacobs. Herder’s fundamental philosophy centered around the idea that the only way for Germany (and thus, any nation) to revitalize its sense of self was through the collection and distribution of folklore, which Herder saw as “the summation of the national soul expressed in the poems of the folk”; the brothers were particularly influenced by this philosophy during their initial collection and revision period. Many of the "not so German" stories they collected, such as "Little Red Riding Hood", were often collected on the basis of the story supposedly reflecting German culture in some way. As Jacob Grimm himself said, "All my works relate to the Fatherland, from whose soil they derive their strength."
He also said this, which further demonstrates his self-awareness that they were collecting and preserving heritage:
Having observed that her Language, Laws and Antiquities were greatly underrated, I was wishful to exalt my native land. . . . Perhaps my books will have more influence in a quiet happy time which will come back some day; yet they ought to belong to the present too, which I cannot think of without our Past reflecting its radiance upon it, and on which the Future will avenge any depreciation of the olden time.
I would recommend reading The Annotated Brothers Grimm (ed. Maria Tatar) for further information as well as the following articles on the subject, all of which can be found online (mostly via JSTOR):
William Wilson: “Herder, Folklore, and Romantic Nationalism”
Terry Gunnell: “Daisies Rise to Become Oaks: The Politics of Early Folktale Collection in Northern Europe”
Jennifer Fox. “The Creator Gods: Romantic Nationalism and the En-Genderment of Women in Folklore”
Louis Snyder: "Cultural Nationalism: The Grimm Brothers' Fairy Tales" and "Nationalistic Aspects of the Grimm Brother's Fairy Tales"