It's a stylistic choice. Here's an analysis, complete with a link back to an old HN discussion:

https://www.pbjstories.com/blog/spaces-around-em-dash

I beta read for a popular american author and they started using spaces too.