for example when we went to Afghanistan when we really didn't want to....
We did, however, say no to fighting in Iraq.
Obviously Canada is an independent country. Quite obviously too the USA is quite 10x bigger than we are and that quite obviously has a lot of influence on the decisions we make.
Saying that means we're not independent though, well that's trolling.
It's interesting to note that Canada's strong advocacy international institutions like the UN, WTO, G20, etc., is likely related to the influence the Americans have over us: If we can convince everyone that every country should be bound by a set of rules administered by an international system then that somewhat binds the Americans and leaves us less vulnerable to whimsy policy on their part, it makes life more predictable for us if there are rules they have to follow.
In light of this you can see why it was so important for Canada to make an example of NOT fighting in Iraq despite a deep desire to co-operate with our Southern neighbours: It's important to us that the Americans exercise their policies in the context of international organizations and so it went completely against our interests to join them in a war outside of one.
In Afghanistan, however, with the blessing of the UN and NATO and so on, we were quite pleased to go along.