Looks and readability matter in writing. I always uses spaces on either side of the em-dash; looks too crowded otherwise to my eye.
I've been doing doing it that way for so long I still often use the "--" construct from way back in ascii email days.
At least I've gotten past the two-spaces after a period I learned from the typewriter. Most of the time, anyway.
To me it doesn't affect readability either way, but to my American English eye the surrounding spaces stands out as extremely non-standard.
In LaTeX:
- A single hyphen designates ... a hyphen.
- A doubled hyphen designates an en dash.
- A tripled hyphen designates an em dash.
<https://ladedu.com/how-to-use-en-dash-and-em-dash-in-latex/>
(I'm not aware of longer dashes native to LaTeX, though I believe doubled en or em dashes are occasionally used.)
Many Markdown flavours incorporate this, such that en / em dash usage in Markdown-authored docs should not be entirely unexpected. I believe many LLMs output Markdown which is subsequently rendered, based on watching intermediate outputs and saved sessions. I tend to adopt LaTeX / Markdown semantics elsewhere.