It helps to remember to be on the same side as the child, not an adversary. No resistance, no lack of closeness.
They feel hurt enough to hit out, distract, when things are calm, ask what had bothered them, and help them find alternative ways to deal with it.
Hitting out is usually when they run out of choices. Empower them with choices, and no one wants to be unhappy. Not an adult, not a child.
It is also important to empower yourself with seeing things as a choice. There are many things you can do, and you can plan them out for times when you are at the end of your rope, so that you don’t ‘short’ into spanking.
For example, one child likes to play video games, another likes to follow elder brother. Evening, everyone runs low on energy, tempers are short, younger one clings to elder, elder gets anger, you can’t cope, you get angry.
You have a choice. An example would be “Hey, little one bothering you? Go take some time off with the video game” (he is much more likely to go willingly than time out as punishment). Then take little one with you, do something fun for both of you (tickling bouts are good for no-inspiration times) and then sneakily take him along to watch elder brother play making sounds to keep him quiet (or he will come to know - make it a game). This way, you empower them to disengage from a volatile situation, rather than fall into it helplessly and get punished for something they were helpless to avoid.
Once you are more used to this, you can actually teach them to ‘deal’ with the situation themselves. For example, the elder could offer the younger an option to be with him that doesn’t bother him so much, or the younger could learn to meet his needs to be with the elder without interrupting him, etc. Is there a possibility for both of them to enjoy the toy, to take turns, to find two fun things to do and swap? The possibilities are endless. You will be more relaxed without all the frustration in the air too.
Of course, this is an example. the point being that no situation is without choices. It is when we think we have no choice that we get violent.