When does the popstate fire? What is it dependent on?

I found that popstate fires when the user presses back or forward button. But that does it mean it is the default behaviour of the browser. Suppose a website doesn’t use SPA, clicking on a link loads an entire webpage from the server. So the URL gets changed and a page gets loaded, pushstate or replacestate is functions only performed by user. So this click doesn’t performs any of this. Now if we click on the back button of the window this does not triggers popstate. Am I correct or both the thing are different? I mean we do not use pushstate/replace state but while pressing back or forward buttons do get fired?

I have been going through this link and I cannot these explanations mentioned in this website:

Example 1 :

Suppose we are on example.com/home, and from here we navigate to example.com/home#s1.
->When we navigate to example.com/home#s1, the webpage isn’t reloaded. The document of this new entry is the same document belonging to example.com/home.

Since the document of both these locations is the same, and we made a navigation, popstate gets fired. The answer is a clear cut yes.

Also, Example 2 :
Suppose we are on example.com/home#s1, and from here we navigate to example.com/home.
->When we navigate to example.com/home, a browser reload is done. This means that the document of the new entry example.com/home doesn’t remain the same as that of the initial entry example.com/home#s1; likewise popstate won’t fire.

The answer is a clear-cut no.

Example 3 :
Suppose you execute the code below on example.com and then navigate to example.com/#about. After this, you go back to the initial entry using the Back button on the browser.

var o = {x: 1}
history.replaceState(o, '');

window.onpopstate = function(e) {
    console.log(e.state === o);
}

What will the console print?

Can you explain these 3 examples this might clear my confusion a lot.