An em dash is used without spaces in most typography manuals. But that’s for typeset books, it’s not like everybody writes that way in casual communication.

I think surrounding it with spaces comes from people using a regular dash (the em dash is not readily accessible on the keyboard), then surrounding it with spaces to make sure it’s not interpreted as a dash.

I use (or used to) mdash with spaces, I've always just found the mdash when it collides with the words to be ugly.

I've read a few typography related books and checked some style manuals in my time, but no-one has ever 'corrected' my usage so I think it's alright.

I was listening to a podcast recently that had interesting information about the birth of mdash - "99% Invisible: The Em Dash".

Episode webpage: https://99percentinvisible.org/?p=46542. (Antenna Pod is a great podcast player!)