Where it shows up
The title tag sits in the page's head and never appears in the page body. You see it on the browser tab, as the headline of the page's search result, and often as the title when the page is shared, unless an og:title tag says otherwise.
Why Google sometimes shows a different title
Google's documentation says title links are generated automatically, and the title element is only one of the sources. The others include the main visible title on the page, headings such as the H1, og:title, other large text on the page, and the anchor text of links pointing to it. A title that is vague, stuffed with keywords or the same across many pages is the one most likely to be replaced.
How to write one
Google does not publish a character limit; long titles get cut to fit the width of the results page. What works:
- One unique title per page, describing that page and nothing else.
- The search the page answers, in the words people use, near the start.
- Your brand at the end, if there is room.
- No repeated boilerplate across pages.