From X-Men, we know that Wolverine was Canadian but in one movie (I think the X-Men Origins) why did he (and his brother) participate in American Revolutionary War and American Civil War on the side against British and Confederacy?
Wolverine and Sabretooth were not in the American Revolution. They were born in the mid 1800s, nearly a century after the Revolution (1775-1783). The first scene of X-Men Origins: Wolverine takes place in 1845, when Wolverine is seemingly a pre-teen (typical age mutant powers emerge).
The American Civil on the other hand, did have James and Victor fighting in it. For the most part, they are both nomadic, hot blooded, strong males of fighting age, and a war would call to them like flames to a moth. They are the eternal soldier type.
Even though they are Canadian by birth *, as evident by their participation in most major wars (American Civil War, The Great War/WW1, WW2, Vietnam), they want to be in the middle of a fight. That said, Canadians were plentiful in the American Civil War, due to multiple issues. Their presence is not unrealistic.
Canadians were largely opposed to slavery, the preservation of which was one of the main goals of the Confederate States of America, and Canada had recently become the terminus of the Underground Railroad. Close economic and cultural links across the long border also encouraged Canadian sympathy towards the Union. Between 33,000 and 55,000 men from British North America enlisted in the war, almost all of them fighting for Union forces. The conservative press in Canada East supported the secession and ridiculed the Yankees as lacking in morality. French Canadians in particular were very highly sympathetic to the Confederacy in the Southern U.S.
The best recent estimates are that between 33,000 and 55,000 men from British North America (BNA) served in the Union army, and a few hundred in the Confederate army. Many of these men already lived in the United States; they were joined by volunteers signed up in Canada by Union recruiters.
Of course, Wolverine, in the comics and cartoons, has a long history of being a soldier, being seen helping Captain America liberate Jewish prisoners (including Magneto/Erik Lesner) during World War 2 multiple times. Even then, he's wearing Canadian flags. Canada, like always, has participated in most major wars, without much notice, due to smaller contingents. Canadians were present in WW2 and even modern day Iraq/Afghan "wars".
*Note: Canada didn't exist as a nation at the time; it was still a group of separate British Colonies.
According to X-Men Origins: Wolverine (which is very loosely based on the Origins comic series), Wolverine was born James Howlett in Canada in the late 1830's. In 1845, he sees his father murdered by their groundskeeper, and that triggers his mutation to activate: bone claws, regeneration, etc. It's at this point that Howlett and his half-brother Victor Creed flee from Canada.
The two of them move down into the United States and decide to join the US military as, in essence, mercenary soldiers. Obviously, they were born much too late to have fought in the American Revolution. However, they did serve in the US military during the Civil War (as Union soldiers), both World Wars, and Vietnam. This would have given them steady work, food, shelter, etc., and would have fit well with the mutant powers they were trying to hide.
In the modern US military, the two of them would have been required to obtain legalized resident alien status (what most people call a "green card") to enlist, but that requirement hasn't always been quite so strict. It's estimated that:
half of all military recruits by the 1840s and 20 percent of the 1.5 million service members in the Union Army during the Civil War.src
were non-citizens. Remaining in the military through the end of the Vietnam War would probably have been a bit tricky, especially without proof of birth or anything like that, but we can suspend our disbelief a bit there and just assume the two of them figured out how to deal with their immortality by that point.