Cats love to groom themselves. Unfortunately, that often means cats get large amounts of fur in their mouths that they wind up swallowing. Then that fur clumps together inside the cat’s stomach, forcing the cat to hurl it out in the form of a matted up fur ball.
Hairballs are normal, but disgusting. To minimize hairballs, consider giving your cat special food formulated to reduce hairballs. There are also supplements you can give your cat to help it ease matted fur through its intestinal tract, which just means you’ll have to clean up its hairball in one form or another.