Why is WordPress swapping double quotes (“) to curly quotes (“) and how do I stop it from happening?

I have imported HTML into a WordPress page, it contains some HTML as follows:

<a class="fancybox" href="bigger-image-path.jpg" title="<em>This is the image caption,</em> by someone">  <picture>   <source media="(min-width: 768px)" srcset="/image-path.jpg 1x, /image-path.jpg 2x"/>   <img class="image-no-border" style="width:100%; height:auto" src="/image-path.jpg" alt="alt">  </picture> </a> 

When I look at this HTML once it is imported via phpmyadmin, the HTML all looks correct as it is above.

But when I look at the page source, the HTML has been changed somehow to the following:

<a class="fancybox" href="bigger-image-path.jpg" title="<em>This is the image caption,</em> by someone”>  <picture>   <source media=" (min-width:="" 768px)"="" srcset="/image-path.jpg 1x, /image-path.jpg 2x" data-category="Open-popup" data-message="popupContent_bigger-image-path.jpg" data-type="popupType_hiddenDiv" data-fancybox-ready="true">   <img class="image-no-border" style="width:100%; height:auto" src="/image-path.jpg" alt="alt">  

Please note the curly quotes after the ‘by someone’ in the title="" attribute in the opening tag.

After testing this only happens when the title="" in that opening contains html tags, like the tags it is currently containing.

This example isn’t a one off, we have many examples of using html in the title="" tags of fancybox tags, so I would like to understand why/how/where wordpress is making this change and a possible solution to stop it happening.