It's definitely upsetting when your cats start fighting. There are several reasons cats may do this and knowing why can help you solve the problem.
Territorial Aggression in the Home
Cats are very sensitive to changes in their environment, and this includes adding a new cat or kitten in to the household. If you don't properly introduce the cats with lots of baby steps and positive reinforcement, you can create a conflict between the cats which may involve fighting. Likewise, sometimes two cats may seem to get along if one is younger, but as that cat reaches social maturity, aggression may occur on the part of the older or younger cat, or sometimes from both equally.
How to Prevent It
The best way to prevent this from happening is by introducing new cats to each other the right way to minimize stress and increase positive experiences for both cats. Cats should be given lots of time to acclimate to each other, with plenty of space to move away, including vertical space such as cat trees, wall perches, and places to hide. In the beginning you want to keep them in separate rooms so they can only smell and hear each other, and slowly increase their access to each other while pairing it with things they enjoy like treats, toys, and brushing.
If you find yourself with two cats that previously have gotten along that are now fighting, treat them as "brand new cats" and go through the introduction for a new cat process.
Territorial Aggression Outside the Home
If you have an indoor-outdoor cat, your cat may get into fights with other cats that come near or into your property boundaries. This is because of cats' territorial natures.
Tips to Control It
Keeping your cat indoors is one way to eliminate these types of fights. You can provide your cat with window enclosures and outdoor "play rooms" to let him or her have some outdoor time but still remain safe from other cats and predators. You can also try ways to keep the other cat or cats from entering your yard, although this can be difficult to do depending on your yard, fencing, and neighbors' willingness to control their cats.
If you have more than one male cat and one or more of them are not neutered, you may experience fighting during feline mating season. Males will fight with each other over access to a female cat even if you don't happen to have a female cat in your home. It's possible they can sense females in heat nearby in neighboring homes or stray female cats roaming outside.
How to Stop It
Neutering all male cats can help reduce this type of aggression as well as unpleasant spraying behavior that may accompany it.
Another form of aggression between cats is related to female cats who have just birthed a litter. If other cats walk near the litter, the new mom may become aggressive to protect her kittens.
Ways to Control It
In these cases the aggression should subside as the kittens become weaned, but you should give the mom and her new babies a quiet place free of other cats until she's comfortable. Spaying, of course, will also prevent this behavior in the future.
Cats that are stressed by stimuli in their environment can "redirect" their anxiety onto another cat, which often takes the form of aggression. Hearing a scary noise or seeing another animal outside the window are the types of stressors that can cause a cat to redirect aggressively onto another.
How to Handle It
In this scenario you will want to identify the stressor that is triggering the behavior and try to remove it, although that isn't always possible if it is a temporary event such as outside construction noise. Give both cats some time apart to de-escalate, and if need be, do the re-introduction process again.
Many species of animals will play with each other by fighting, and it may look scary but be perfectly fun behavior for both of the cats. However, play fighting can slide into actual fighting if one or both cats becomes over-aroused and agitated. Since play is a great outlet for any animal, you don't want your cats to stop play fighting if they are truly enjoying it, so you should supervise play of this type and look for signs outside of the ordinary. Move to distract the cats if the play fighting starts to escalate.
Handling Inter-Cat Aggression
It's very important to know what to do to stop your cats from fighting. Never intervene physically as you can get seriously hurt, and avoid using anything aversive as this can make the cats even more aggressive toward each other. Rather, focus on distracting and separating them, then working on ways to reintroduce them and provide positive outlets for their behavior.