Wars for national independence are not really won by weapons. Instead, they are won by morale and motivation. Nationalism can give the rebels the motivation to keep fighting even when things look bad and to make serious sacrifices for their cause.
The colonizing country can really only win a war for national independence if it makes people stop wanting to fight. This can be done by completely crushing them militarily, but that is very difficult. What is really needed is to make the people feel that independence is not worth the suffering that the war causes. Nationalism prevents this from happening. It makes people feel that gaining their independence is the most important thing in the world. This keeps them going and makes it so that they never give up. Often (as with the British in the American Revolution and the US in the Vietnam War), the colonizer gives up and goes home because the war is not important enough to them