There are many case in canonical url.
Case 1: When the url is opening in the both the version of http and https (Google consider as separate site and thus duplicate issue arise)
Case2: When the url is opening in both the version with and without www( Google consider as separate site and thus duplicate issue arise)
Case3: Consider the following two url
www.abc.com/ and
www.abc.com/index.php?
Both redirects to the same page with same title but with different urls and thus duplicate issue. To avoid this issue, canonical tag can be added in the authoritative url. Google will consider both as same url.