The same content is often reachable at many URLs — http and https, www and apex, with and without trailing slashes or tracking parameters. The canonical tag tells engines which one is real, so ranking signals consolidate instead of splitting across variants.
Best practice: always use absolute URLs (https://www.example.com/page, never a relative /page), keep one canonical per page, make it self-referencing on the primary version, and ensure the canonical, sitemap, and internal links all agree on the same variant.