As a general reminder, you should always look at what HTML code you generate. There are three important layers:
Your PHP template.
The generated HTML code (use your browser’s “View Source” view, Ctrl/Cmd+U in most browsers).
The document tree as understood by the browser after parsing the HTML (and possibly executing some JavaScript code). You can see that one by using “Inspect Element” in your browser.
You generally don’t need to check all three layers all the time, but in front of an error it can be useful to do just that. For instance in your case:
<!-- PHP source -->
<h1><?php echo $something ?></h1>
<!-- HTML result -->
<h1><p>Something</p></h1>
<!-- Document tree -->
<h1></h1>
<p>Something</p>
The P element is illegal inside a H1, so the browser closes the H1 immediately, then you have a paragraph, and finally it discards the </h1> closing tag (which is now matched with nothing, since the H1 is already closed).
That’s not specific to Kirby, but a PHP feature. Since PHP 5.4, this feature is enabled by default. So you can use it for your Kirby sites without thinking about it.