Allow users to use embedded HTML tags in custom blocks
The W3C specs (https://www.w3.org/TR/2011/WD-html5-20110525/the-button-element.html#the-button-element) show that a button allows phrasing content (https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#phrasing-content), e.g. a &lt;span&gt; to be placed inside a &lt;button&gt;, but not a &lt;div&gt;, so your WYSIWYG editor is correctly rearranging the elements.

Perhaps you could rework your code to allow for a &lt;span&gt; to be used inside the &lt;button&gt; and style that instead.