In current D&D games, alignment is a fairly broad subject, because it impacts certain triggers: Some spells only work on creatures of a particular alignment, some magic items only work for characters of a specific alignment, and alignment has enough definition that it spawns arguments about how much the choice of alignment should influence character behavior.
Going back to D&D's roots, there's a strong vibe that D&D's alignment system was heavily influenced by Michael Moorcock's work. In Moorcock's books of Elric of Melnibone, the forces of Law and Chaos are locked in a bitter war to decide the eventual fate of the cosmos, and Elric weaves his way through both sides (usually, but not always, with Chaos as his patron). The very choice of the word "alignment" seems to bear this out: a character is "aligned with" the forces of Law, or "aligned with" the forces of Chaos, or "aligned with" Neutrality, refusing to join either side. (This also seems to be a likely influence for the druidic Neutrality in D&D0 -- druids are not concerned with the politics of humankind in the war between Law and Chaos, instead favoring the cycles of the natural world, and thus they are Neutral in that conflict.)
From this perspective, the ability to detect someone's alignment via spells like detect evil, or the use of alignment languages, makes a certain kind of sense. Having an alignment isn't just a commitment to a particular set of principles -- it's an active decision to join up with a particular faction in a cosmic war. That faction has its own rules and its own secret language -- hence alignment languages. When you detect evil, then, you're not just looking for "evil thoughts," you're looking to see if this person has signed up as a member of the forces of evil. It's the ability to sense a conscious, deliberate commitment on the part of the target!
Advance a few years, when this sort of idea is scrubbed from the setting. D&D has alignment, but it's more of a moral compass and sometimes a tag for magical effects. The notion of it being connected to a cosmic war is pretty far removed, as the various settings for D&D now assume more cosmopolitan pantheons of deities rather than a stratified war between Chaos and Law. There's still a detect evil spell and a know alignment spell, though, so now you're not detecting whether someone is "aligned" with one side or another in a cosmic war, but whether someone is an adherent of a particular set of behavioral principles.
The tricky part now is that you have a repeatable, objective standard for determining aggregate behavior. Your detect evil spell gives you a specific yes or no result that tells you when someone has been naughty. Based on this, you can say with certainty -- with some testing -- what kind of acts constitute evil. You can explicitly call someone out as being evil. You know, based on this objective method, who's evil and who isn't.
Once you go down this road, you now have a justification for that "kick open the door, kill the bad guys" behavior. Your detect evil ability infallibly tells you "This person is evil," which is not hard for players to extend into ". . . and thus it's ok for me kill him/her/it," especially if evil in your game means that the creature in question will inevitably turn on you if spared (as it does in the Dragonlance setting).
One story related in Dragon magazine described a character who always, without fail, would attack and kill anyone who detected as evil. The DM built a convoluted mechanism to "punish" this player by divine fiat, in order to discipline the player for making this "assumption." The problem with this is that the player wasn't making an assumption, he was acting according to the rules of his world. In the setting with a detect evil spell, you have a reliable barometer that always tells you if someone is evil or not, unless they're taking magical steps to conceal their alignment. In other words, what you have isn't just magic, it's a form of technology. It tells you someone's evilness just as surely as you could measure their height with a yardstick and say "Yes, this person is over two feet tall."
In short, the existence of detect evil means the existence of objective standards of evil, which means that taking precautionary behaviors when you can detect that evil is in some ways justified. Not rigorously -- essentially you're using evil profiling to justify pre-emptive strikes -- but it certainly grants some weight to the notion that an otherwise "good" character is justified in attacking an "evil" character and in killing "evil" monsters without ever giving them an opportunity for dialog, because they are, by an objective standard, dangerous and unable to be trusted.
Of course, if you're running an adventure like The Temple of Elemental Evil, this helps you out. You're perfectly justified in kicking down the creaking wooden doors in the moathouse and killing all of the brigands in there, because you know that they are objectively evil. There's no awkward discussion with your kids when you introduce them to D&D when you have to explain that killing orcs in their homes and taking their stuff is still "good" because we know that the orcs are evil. (Let's just put on our cultural insensitivity hat and say that our culture values are "good," so the enemies of our culture are "evil," and it's ok to kill them!)
This also means, interestingly, more arguments about alignment, because different players and DMs will have different ideas about what constitutes an evil act (it's subjective), while the existence of the spell means that there must be some settled, objective standard. Naturally, this means that when the DM decides that something is evil and a player disagrees, there's an argument not just because the rules are in conflict, but because there's a values conflict between the DM and the player.
What do you do about this? You could get rid of the detect spells, or perhaps change them to sense unnatural things -- undead, elementals, extraplanar beings; things that are not of this world. There's no moral judgment there, just detection of an inherent property of a creature from or powered by "some other realm." Or you could go back to the idea that alignment is not just ideology, it's actual allegiance to a specific faction. Then your detect spell isn't just looking for behaviors, it's looking for whether the target is on Team Red or Team Blue.
No wonder 1e AD&D describes the use of detect evil or know alignment as a huge social faux pas. If you could just use these abilities willy-nilly, you'd be able to parse out all of the people you could trust, all of the folks who are primed to be part of your group and ready to uphold your values, and make sure that your team -- heck, your whole society -- ran in accord with your vision. You could literally have Kingdom of Good vs. Kingdom of Evil, with people jailed, executed, or deported based on the results of a divinatory spell.
Naturally, that doesn't work so well when you talk about adventuring parties, where often the group includes people of various moral and ethical standards, some more rigorous than others. But then, adventurers have always been cast as outsiders to mundane, settled civilization...