…a way to stop this autofilter (as I think that is what is causing it) by some CSS code or something…
I would guess that would be quite a challenge using php to “edit the editor”.
Are your pages actually being written in the editor or are they being pasted in from another editor? If pages are first being written elsewhere, anything other than “plain text” in its rawest form could be bringing things in that are triggering the WordPress editor to add the spaces either then or later.
Another thing to try as a discovery experiment might be to go to “text mode” and copy whatever is there into a code editor (true “plain text”) where search-and-delete could get rid of anything and everything other than what should actually be there, then see whether the WordPress editor nevertheless continues to act as it does.