To get an animal out of a boat, first, you have to press F3+B to see the hitboxes of the boat and animal
Then you need to lead the animal and make them stand. Once they stand on top of the boat, then you can destroy the boat without hurting the animal with a sword.