For example… Speeding
Going down the highway doing 10 oven the limit and you get pulled over an dgive a hefty ticket… But Nothing bad happened.
Another example… Letting a Tesla do full self driving but you aren’t paying attention. The car is driving itself quite well but you are ticketed for undue care and attention… But there was no accident or anything… Nothing happened.


If everyone started driving 10 kph over the speed limit we’d see a significant uptick in the rate of accidents. That is just a fact.
We don’t want that so we’ve set limits that still get you where you’re going as fast as possible while keeping that particular stretch of road relatively safe. To enforce those limits we’ve decided that if you get caught going over you get punished for it. Not for driving fast per se but for breaking the rules you agreed to in order to be allowed to drive there in the first place. Fining you even when you didn’t get into an accident is just carrying out the threat so that it keeps its credibility.
spoiler
Also, as a related sidenote: I don’t believe in free will so in a way punishing people even for murder doesn’t really make any sense since in my view they could not have done otherwise and simply can’t help themselves. I view a situation like that in a similar way to a bear mauling a person in the woods. What sense does punishing the bear make? It’s a bear for crying out loud - what did you expect it would do? However, we’re not bears. People regularly get the urge to similarly maul another person but most of the time they don’t because they know they’ll get in trouble for it so in that sense the punishment makes sense. Not as a punishment per se but as a deterrence to protect others. If you did a bad thing despite the deterrence the only tool we have left is to lock you in a facility so that you don’t harm anyone else. It’s like shooting a bear that wandered into a neighbourhood. It’s not to punish it for doing so - it’s to protect innocent people.