Sometimes cats will stop using their litter box and poop outside the litter box instead when the litter box is too dirty for the cat.
Make sure to keep the cats litter box cleaned at all times and free of any cat poop so that your cat will use the litter box instead of the floor.
If the cats litter box is clean then sometimes the cat may have health issues that need to be checked out by the vet when they suddenly stop using the litter box and start pooping on the floor.
When you catch your cat pooping on the floor don't be mean but instead just direct the cat to the litter box in a friendly way and they may start using the litter box again.
Try placing some aluminum foil down where the cat is pooping and they will not like stepping on the aluminum foil and usually will decide to start using the litter box again.
Also stress can sometimes make a cat poop outside the litter box so try reducing stress in your home around the cat if possible.