This is known bug from Sitecore, see link - https://support.sitecore.com/kb?id=kb_article_view&sysparm_article=KB0365101
Experience Editor/Page Editor may stop working correctly and not allow to edit item fields on the content pages that generate invalid HTML markup.
Above Sitecore link states -
A few examples of such markup:
1. Item presentation contains nested components that both render <p> tags, resulting in the HTML markup like this:
<p>My <p>text</p> which gives trouble</p>
2. <div> tags being nested inside <p> tags:
<p>This is a text block <div>but this one is a container</div></p>
3. Unclosed <div> tags:
<div><p>Lots of data included here</p><div>But the outer div is not closed</div>
Ensure that Sitecore items generate valid HTML markup. It is possible
to use HTML validation in Microsoft Visual Studio or W3C Markup
Note: Some of the issues with invalid markup were fixed in Sitecore
8.0 Update-6 and 8.1 Update-1. However, please avoid using invalid markup all the same.
You can also follow - XHTML markup is incorrect near placeholder "header" Error, only for "header" key