What a canonical tag does
The same content is often reachable at several addresses: with and without www, over http and https, with tracking parameters, with a trailing slash or a sort order. The canonical tag names the one address you want indexed, so ranking signals are not split across copies.
Search engines treat it as a strong hint. They may override it when it points to a redirect, an error page, a noindex page or content that looks different.