“What a great quote! It’s so inspiring! I’m going to use it to undergird my philosophy of life!”
Okay, probably a bit on the nose. But people are influenced (usually subtly) by memorable statements. So it’s important to not only understand them, but also to be aware of who is behind them. In the case of fiction, the character is probably more significant than the author (unless the author is Ayn Rand). “Greed is good”* was never meant to be aspirational, but to highlight the flaws of Gordon Gekko. Similarly “There is no good and evil, there is only power…and those too weak to seek it.” should not be attributed to the author as though they agreed with the sentiment: it’s attributed to Voldemort, a card-carrying supervillain if ever there was.
So, who should Harry Potter (and his readers) look to for moral guidance? There are a large number of characters surrounding him, most of them ostensibly on the side of “good”, but who to trust?** Once you’ve filtered out the obvious baddies, what of the rest? Almost all of them are painted very human—that is to say, while they may present a good example at times, they don’t always get it right. They have flaws. They make mistakes. They exhibit behaviours that you wouldn’t want to emulate. Harry struggles with this dilemma very explicitly: he wants to admire and look up to his father, James, but then discovers what a jerk he was as a teenager***.
But throughout the series, Harry is presented as looking up to (even though not always getting on with) one character: Albus etc. etc. Dumbledore. By extension, the reader is encouraged to view Dumbledore as a mentor, hero, and good example. At least, before the revelations of the Deathly Hallows. But even then, Dumbledore appears as a posthumous advisor (with it left open as to whether it’s actually him, or just Harry’s imagination). In a way, though, learning more of his history and his faults makes Dumbledore a better example: we know he’s been there, done that, has struggles that we can relate to, so it reinforces what he says (e.g. “It is important to fight and fight again, and keep fighting, for only then can evil be kept at bay, though never quite eradicated.”).
However, don’t let that stop you analysing any statement, from Dumbledore or anyone else; it’s often interesting to explore nuances and try to figure out how something relates to your given situation. After all, you can have all the good advice in the world, but ultimately you are the one making the choice. “_____ said to do it” isn’t much of a justification, and isn’t going to impress the Judge.
* And yes, I’m aware that this is a paraphrase rather than a direct quote. It’s what everyone remembers him saying, which reinforces the way audiences can be beguiled by a charismatic villain or a snappy-sounding quote.
** Which, in a way, is one of the recurring themes of the series; there are betrayals, spies, doppelgänger and the like in every book.
*** Lets be honest (at least, those of us past that age), which of us didn’t behave like a prat as a teenager? Fortunately, most grow out of it once our hormones and so forth settle down.