While using a sword in a sweep attack, the mobs around you will get attacked, and also you may kill too many farm animals as well as babies during the attack.
The better way to save these farm animals is to stop a sweep attack. For this, you have to –
Double press the forward button and hold it which will help you to do a short sprint in the time of attacking. As a result, you can save your farm animals or your friends of the other villages while doing sweep attacks.
And you can disable the sweep attack by pressing the Shift.