Why duplicates happen
The same content often lives at several addresses without anyone intending it: with and without a trailing slash, with tracking parameters like ?utm_source=, under http and https, on www and non-www, or in both a category path and a tag path. Search engines see each as a separate page and have to guess which one matters.
A canonical tag in the page head removes the guess. It is a strong hint, not a command; if other signals disagree, such as internal links pointing elsewhere, search engines may choose a different canonical.