As always, pointless acts of violence create a debate in which people try to reason why the perpetrators have behaved as they have.
And thereby hangs the problem.
You cannot attribute rational thought processes to people who behave in this way.
Questions like "What were they thinking?" in terms of consequences, for the victims and potentially themselves are irrelevant because they weren't thinking - at all.
An action like this is created by an instant impulse, with no thought or reasoning behind it. How could there be? A second's thought would prevent the act for all the reasons that rational thought provides - potential fatality, criminal proceedings, prison, and so on.
That is why notions like hanging and birching as 'deterrents' are redundant.
In order to appreciate that there is a potential serious punishment for your actions, you need to be thinking through your actions before you carry them out - and in cases like this, that simply does not happen.
No-one commits a punishable crime with the thought in mind that the punishment will be visited on them personally - that means that reasoning and considering and looking ahead are all in play, and of course, they are not, none of them.
Punishment should be meted out, but in a way that genuinely informs the culprits of what the punishment is about - otherwise it will fail in its intention, which is to make them consider what they have done, regret it, and resolve not to repeat the experience.
Concepts like hanging and birching and similar are simply knee-jerk reactions where instant violent revenge feels appropriate in order to assuage feelings of shock and abhorrence. They are completely understandable human reactions from rational minds to irrational savage actions - but they are not appropriate.
Our laws are what make us civilised - and a proper judicial process and appropriate punishment must be completed - and further violence, albeit state sanctioned - has no place there.