As mentioned previously, when I got into D&D I didn't really have much context outside of my love of Fighting Fantasy books, and magazines such as Dragon and White Dwarf, which were at the time very combat-heavy.
Heck, White Dwarf featured a comic strip about a Barbarian cheerfully murdering everyone he came across.
We all thought that D&D, or any RPG for that matter, was about swords, sorcery, loot, and survival.
It's a common trope that parties often turn into wandering serial killers, but that wasn't really the case in most of the campaigns we were in. Yeah, there was a lot of stabbing, but only people we (our characters) felt deserved it, or in self-defense.
There were a lot of grey areas, of course. The dungeons we were delving might well have been the rightful homes of law-abiding dragons, from a certain point of view.
Alignment Rail-Roading
So, if that is true, what is the problem?
My feeling for a long time has been that players respond to the plot and incentives put in front of them.
It's a little weird as a "forever DM" to blame the game master, but apart from the rare jerk, most players want to succeed, have fun, and mostly make good choices.
If they get rewarded for being bad, the pendulum can start to swing toward doing more bad things.
Guilt & Consequences
A nice way to drop a cold dose of conscience is to leave guilt-trip easter eggs:
Alignment Points
Another option is to give players' characters alignment points.
At my table, I don't allow evil PCs, but characters can become evil by their deeds. Once a PC becomes evil I will take them over and they become a villain.
Think of it like XP but for evil actions. Or hit points but instead of character death, they become beyond redemption.
Of course, a player who knowingly goes into a campaign with this hanging over them is unlikely to send a beloved character to their evil doom this way, if they don't care about the character they have other, easier ways to switch.
In-Game Consequences
The above options might feel subtle or abstract, which is where the final option comes in.
You break the law, the law breaks you.
Once a party gets a reputation for killing shopkeepers rather than buying things, the game world is going to push back.
I mean, what would your community do if they heard a small group of psychopaths slaughtered a tavern full of innocents because they were thirsty?
Especially if your community was armed with farming utensils and weapons remaining from the last Ogre incursion?
Think the city watch can sit idly by?
Or maybe the thieves guild doesn't like the competition? Strangers working their patch without paying tribute?
Bottom Line
This is the kind of thing that should be decided in a game zero.
It has to be said clearly, we are not talking about taking away player agency, just setting some boundaries. In my adventures, the players are heros. Not always voluntarily, or eagerly, but they are heros.
Of course, if letting players go on a killing spree is fun for all involved, go for it! I, personally, don't allow willful player-on-player violence, however.
I've only really talked about the stabby version of evil. Hopefully, your players wouldn't wander into other, sicker, variations ... but maybe affirm that those are off-limits too.