The first is because the different groups disagree about who should be in charge, or how the country should be run. If two political parties disagree about the result of an election, this might lead to a war if the two sides cannot or would not come to an agreement.
The second is because one group of people does not want to be part of the country anymore. This is known as a war of secession. Lots of people living in a certain area might decide that they want independence to make their own country. Very few national leaders would be happy to give up land that is part of that country, and a war could result.
Sometimes the people who want to break away do not necessarily want to form a whole new country, but they might want more autonomy over their affairs. This happens sometimes when different ethnic groups belong to the same nation.
Civil wars can go on for many years and be just as destructive and damaging as international wars. Civil wars tend to become complicated very quickly. A civil war might start between two sides, but groups might break up and the new, different sides could start fighting each other. Groups who were not involved at the beginning can easily be sucked in, as they fight to defend themselves against both sides. Civil wars with many different sides all fighting each other have occurred. Sometimes foreign countries help one side, or different countries help different sides. This can become a proxy war.
Civil wars include: