A canonical tag simply tells a search engine that the original version of a page is at a certain address.
This is the syntax;
<link rel=“canonical” href=“https://example.com/sample-page/” />
It goes in the head of your HTML document.
If you had a page that was accessible by several different URLs (faceted navigation for example) but basically has all of the same content, you can designate the original or main source of that content with a canonical URL. Google can sometimes chose a different canonical but usually doesn't.
Here is a great blog post by ahrefs on the topic.