The excerpt of law you provides says that a person who joins the armed forces of a foreign state has to also acquire foreign nationality, in order to lose US citizenship. And even this can be overridden by statute.
It is still US law, not Canadian law that determines US citizenship.