Is this just the local NPC begging them not to go, or are you more on the nose about it?
Typically it's telegraphed by the world or them getting a glimpse of the thing in action before having a chance to tackle it themselves. If you have an NPC tell the players "It's too dangerous" they will never be sure if you are trying to warn them or if you are setting them up to be big damn heroes. You need something more reliable and clear-cut. Something that gets the meta info to the players, but which also feels like it's part of the world.
If your players are smart and tuned into your vibe, you can do environmental storytelling for them to get it. "You enter the knight's barracks and see nothing but bodies torn limb-from-limb". It can work, but again, they can misinterpret. The most direct way is with the roll as I mentioned above, but a close runner up is give them a solid comparison with a known quantity.
If they're an ally NPC who you've shown is a badass, a whatever level fighter and he can attack 5 times in a turn or something, and the players see a monster smoke that guy in a single round, they will pay attention. If they spent a whole story fighting a red dragon that they beat to a standstill before it teleported away in retreat, and then a story or two later they find the villain wearing that dragon's skin as armor, they will know some shit is up.
The thing is to set up situations where they can get a demonstration without being in the engagement proper. The easiest way to do this is to give them the demo at a distance. They can look through a spyglass to see the battle happening, but they're too far away to get there before it's over. They can see the action happening over a video connection (for modern settings) but they're 20 miles away. That sort of thing. Darth Vader choking dudes to death over an intercom while having a casual conversation is a great movie example of this.
Oh! Also cutscenes are a good way to do this. Just straight up give them a scene of some shit happening at the villain camp and it's just showcasing how much of a badass the bad guy is, and how evil they are. Great method and totally seamless. And it's not even really a meta-gaming problem because knowing a bad guy can tank through fuck-tons of damage and hits like a freight train doesn't really let them know what to *do* about any of that.
This is also a good way to allow the bad guy to get heir good villain taunts in without putting them in harm's way. I used to have a player who would, as a rule, interrupt ANY villain monologue to try to kill them. I now assume any baddy I put in proximity to the heroes *could* get jumped, and if the dice fall right, *could* get killed at any moment. You just never know. So instead of that, you have the villain's presence be active, but not local. They harry the party through blood scrawled taunts left on the walls of towns they raise, they send messengers to them that deliver body parts of their kidnapped loved ones (and if you want it to be really fucked up, have other loved ones deliver the messages, but they're under some sort of curse or they have a bomb collar or something so they have to return to being a hostage for the baddie or they die). Proper archvillain shit. They appear in magical or technological holograms above town and tell them how insignificant they are. That sort of deal. Then when you finally have the villain show their face for real, the party is in full
"let's go kill that bastard" mode, and you are left free to make the villain as nasty as you want to live up to their rep.
In two years of D&D, none of our DMs has ever put the party in a situation they couldn't win. Hell, we've never lost a fight in any game session. Part of that is the systems we've played: Pathfinder, D&D, WWN, and 13th Age. They're all Big Damn Heroes systems.
It will undoubtedly happen in our DCC game, but it hasn't yet.
One thing that makes me really eager to try Masks: A New Generation as my next system experiment, is that the system does not have a "death" state per se. You don't lose health in combat, you take "conditions' and when you're full, you're simply "out of combat" and the manner in which you were taken out is narrative, but is not, by default, death. It might mean you flee. It might mean you get knocked out. It might mean you were teleported to the dawn of time. You're just no longer able to interact with this scene. But within that broad spectrum it allows for a lot of those dramatic beats without having to worry that you've over-tuned an encounter in such a way that you end in a TPK.
But in tabletop? A lot of the fun is interacting with the environment and the characters, and it's a lot harder to railroad.
And I think this gets exacerbated because there is a mentality in tabletop, not every table, but I think we can all think of examples where it feels like tabletop is a PVP game. It's players versus the dungeon master. And that took me awhile to sort out as a player. I don't think a lot of people ever do. The DM is not your enemy. They want you to get higher levels and do cool things. That's the reward. But there is a certain player attitude that treats the relationship as a competition, and those are the players I find that just dig down and look only at damage HP and how many healing things they can get away with versus actually creating a compelling group narrative where perhaps this is an opportunity to flesh out your character.
This is something I address very directly in my intro sessions. I tell folks exactly the sort of DM i am and I let them know that typically speaking, I want to see the end of their character stories as much as they do. "You're not likely to die, but you'd be surprised what you can live through" is a common thing said at my tables. I usually talk about how min-maxing, while fun, won't do a lot in my campaigns because I will tune the monsters and threats to the players, and unlike them I don't have to follow point allocations and such. By design, the DM can always manufacture a bigger gun, because they run the rules, they are not bound by them. That tends to take the wind out of that approach and get them thinking about the thing that will fit with the campaign, which is character.
Granted, I also tend to feel out my players before we play anyway. I play other stuff with them to see how competitive they are, if they are prone to that min-maxing vibe. It's usually not just confined to ttrpgs so you can sort of pick up on it in other games. I try to seek players who like the same stuff I do (or at least complimentary stuff) in the hobby. That way we're all likely to have a good time. Not all friends are D&D friends.