Your DM was, frankly, incompetent.
Here's how it worked in the games I was in.
Me: My paladin casts detect evil. Is he evil?
DM: Sure.
Me: "Surrender or die, varlet!"
DM: Well, let's see. The guards -- who are not evil, by the way -- move in to disarm you. If you explain you used Detect Evil on...