In case it helps anyone, I have found a way to resolve this, which I will use when I need to get the html. (I don’t want to use an html editor external to WordPress/plugins because an online one I tried added extra stuff which wasn’t there when I finally got WordPress to show the html, and also; in life generally I tend to try to avoid adding extra potential complications unless necessary – sticking to the WordPress environment for editing means there’s less chance of something going wrong).
TinyMCE Advanced/Settings/Classic Editor(TinyMCE)/Advanced Options
Keep paragraph tags
Recommended for better compatibility with the Block Editor (Gutenberg).
Stop removing the <p> and <br> tags when saving and show them in the Text editor. This will make it possible to use more advanced coding in the Text editor without the back-end filtering affecting it much. However it may behave unexpectedly in rare cases, so test it thoroughly before enabling it permanently. Line breaks in the Text editor would still affect the output, in particular do not use empty lines, line breaks inside HTML tags or multiple <br> tags.
For a non techie like me this looks slightly concerning so I will not leave it enabled all the time.