Magic in Tolkien's universe is a very important topic, and if you get confused about it you could really take away some really weird impressions - like the poor early confused reviewers that thought the whole thing was an allegory of WWII.
'Magic' per se in Tolkien's universe doesn't exist. All the 'wise' characters affirm this. What is perceived by the unlearned as magic is one of two things: advanced technology or else a natural gift that the person was created with (or sometimes both at the same time). So for example, at the beginning of The Hobbit, the narrator affirms that the magic of Hobbits is that they can move around very quietly and secretly: "There is little or no magic about them, except the ordinary everyday sort which helps them to disappear quietly and quickly when large stupid folk like you and me come blundering along, making a noise like elephants which they can hear a mile off." Essentially, what seems magical to "large stupid folk" is ordinary stealth to a Hobbit, because they are naturally gifted when it comes to stealth.
The same thing applies to the Hobbits interactions with Dwarves, Elves, and to a large extent even wizards. To the Hobbits, Gandalf's magic is recognizable to us as just extraordinary talent with fireworks - a product of technology. His real 'magic' he keeps hidden. To the hobbits, the toys made by the Dwarves are 'magical', but we might well recognize them as windup toys and other objects of advanced mechanical skill. To Sam, the rope made by the Elves seems magical, but when he asks them about it, they have no idea what he means and answer, "Well, it's certainly well made. If we had known the craft delighted you, we could have taught you much." When characters in the stories talk about "magic", they are mostly talking about something that they themselves can't do and can't even imagine how it is done. But, some one can teach you how it is done, if you have a talent for it.
When Galadriel is asked about 'magic' she expresses confusion over what the word even means, and hints that she finds the word not particularly useful because it is such an umbrella term that it covers things which are completely unalike. However, she tells Sam that she will show him "the magic of Galadriel", by which she means what she can do with her knowledge and authority.
Authority is a big deal in the Tolkien universe. Beings in it can do things because they have the authority to do them. All the authority in the universe is delegated by its creator, and beings can choose to use or misuse that authority. Maiar, elves, and humans each have a certain sort of authority over the natural world, which allows them to reshape the world to suit their designs. Humans call their magic 'technology' because they understand it, but it's not really that different than what elves or maiar can do. Maiar and elves just do it a bit more directly because they are more plugged into the world, while humans are not native to it but simply sojourning in it. Gandalf's magic as a "wizard" turns out to mostly be his authority as a spiritual being over certain aspects of the universe, combined with authority granted to him as a vassal of more powerful spiritual beings for the purpose of the mission (symbolized by his staff), combined with the authority he gets from wielding a Ring of Power (more on that in a bit), combined with his deep education. Gandalf's "spells of opening" if inspected turn out to be more like what we'd call "passwords" - proof you have the authority you claim to have, and when he finally does open the door it is explicitly a "pass word" that he uses.
The closest thing to 'magic' in the D&D sense in D&D is that you are allowed to pour a part of your authority into the things you make, transferring your authority to them. This happens at a natural level, of for example a son inheriting his father's authority, or at the level of technology where you can bottle the essence of authority and invest it in an object. Essentially, if you make anything with enough love and appreciation for what you are making, if you care enough it make your best, if you put a lot of emotion into the making of it, and you make it well then this happens, and the result is a 'magic' item. The Rings of Power are the most salient and powerful examples of this, as they essentially bottle up a portion of the authority of a whole race and focus and amplify it, so that the wearer of the ring inherits a huge portion of the authority and natural gifts while amplifying his own. But there is still some sense in which they are just multi-dimensional technological artifacts - Clarke-tech if you will.
So whenever Tolkien is talking about magic, he's usually talking about knowledge and technology. And he wants to distinguish sharply good uses of technology that increase comfort, security, and beauty compared to the misuse of technology which is short sighted and destructive. He compares the good use of technology to the Medieval notion of "Natural Philosophy" (or perhaps Theurgy), the White Magic that you could learn by studying the world and using your natural authority rightly. And he compares the misuse of technology - even if it's something that's literally technology like a steam engine (such as Sarauman builds to run the Mill at bywater) or gunpowder (such as the blasting powder Saruman uses to destroy part of the wall at Helms Deep) when its used for destructive purposes - to the medieval notion of Goëtia. Goëtia was black magic that came by communing with evil spirits and trying to transcend the natural bounds of your own authority so that you could rule over things you weren't meant to or in ways you weren't meant to. Goëtia represents the temptation to do things that you know you ought not do, and is embodied in The One Ring, which is Sauron's attempt to transcend his own authority by stealing everyone else's authority and hording it as his own, effectively making everyone and everything else in the world his slave. This is why Galadriel is so confused by the word "magic" because it joins together two things that are for her opposites. She knows how it is all done, and to her its two very different 'crafts'.
Aragorn's "magic" is simply a really good education in healing from Elrond, combined with natural sciences (natural compounds from plants), combined with the fact that as King he has inherited a certain amount of authority over his subjects which, if they are in their natural (good) state, they'll be inclined to obey. So Aragorn can go and call back Faramir's despondent broken spirit, and Faramir's spirit would be more inclined to obey Aragorn, because Aragorn is his good and rightful king.
If you get this wrong, then you think that the story is somehow anti-reason or anti-technology, when Tolkien is really just critiquing what people use technology for ('rings' in his opinion, which is what he referred to the 'atomic bomb' as in his letters) rather than what they should use it for (blessings, if you will).