This is an interesting question. One I find myself wondering about more and more as I play D&D.
Do I only set up fight that are challenging enough regarding player level? Should I try and balance the fights on the scale of an adventuring day? Should I only consider the scenario and make the most likely encounter occur considering the situation and not the challenge required? Do they have to stand reasonable chance for each fight?
Mostly, I think that the approach I have is wrong, and my player's approach too. No one likes to fight. Everybody wants to avoid fights. Even fights you're likely to win. Especially those fights, because, if you're opponents are smart, and know they might lose their lives, they'll most likely want to avoid it. My players are always itching for a fight, because that's what they're playing D&D for, they want to roll the dices, do damage and cast big spells, they want to fell the beast. But even if you have no doubt you'll triumph, the beast can bite.
I noticed that my players, even if I warn them that some creatures aren't just there waiting to be killed, and some might teach them a lesson, I see in their eyes they always kinda feel betrayed when it proves too much of a challenge. I wondered "How to do it?"
Alll of that brings me to that matter of "evaluating" an opponent's power. The tools to do such a thing are not really emphasized in D&D 5. I suggested to my players that they should, when they spot something or someone and things start going south, they should try and evaluate the threat. I'd ask for insight or perception or investigation checks. I also tried to tell them, especially since they're growing in power, that intimidation might be a powerful tool and avoid them to spend some valuable resources. But I don't know... it feels like they distrust those methods... they don't feel like it's very intuitive. But I have to admit, the game isn't built around them. There are lots of spells to burn or ice your ennemies, but none to tell that they'll most likely tear you to shreds. Only clue my players seem to value for that matter is basic lore, my intonations, and meta-gaming clues ( It's that kind of monster, I know it's bad/fair game/useless...)
I should probably think of some elegant powers and spells meant to evaluate the power or the offensive abilities of a foe.