Go to http://en.wikipedia.org/wiki/Canadian_Confederation#Influenc... and look at the #1 external cause. That doesn't say much about the history, but does confirm that fear of US invasion was important to Canada's formation. Sure, a lot more internal reasons are given, but that external one was by far the most important and drove the timeline.
Here is more background on that. The official policy of the USA was that it was their manifest destiny to expand/conquer/control a variously defined part of the world that always included Canada. In the 1840s the USA launched a fairly unprovoked war on Mexico and annexed half the country. Coming out of that war, the USA negotiated a treaty where they took a large chunk of British territory in the great plains. Then the USA fought the bloodiest war in history to that point. (The US Civil War.) Coming out of that war the USA was hostile to Canada with the Secretary of Defense making comments indicating that Canada was next. And the Fenian raids (see http://en.wikipedia.org/wiki/Fenian_raids for more) were being launched from US territory against Canadian targets.
2 years and a week after the ending of the Civil War, the act of Confederation created Canada as a single country. 3 years and 11 months after that, Canada had achieved approximately its current borders. (The USA did manage to take the Alaskan panhandle from BS, Newfoundland didn't join Confederation until after WW 2, but the country was recognizable.) And the #1 goal of the new country was to build a railroad across its southern border so that troops could be moved to meet any possible US invasion.
For more historical background, the original separation of Quebec into Upper Canada and Lower Canada (now Ontario and Quebec) was to accommodate refugees from the newly created USA who wished to remain British subjects. In the USA they are called "traitors". In Canada they are still called "loyalists".
And to this day Canada has no real national identity other than, "We're not Americans."
So there. Thank you for proving how little Americans know about Canada, and hopefully you learned something. If you have any follow-up questions I would suggest doing a Google search and reading appropriate Wikipedia articles first.