My Mac keeps adding double spaces randomly when I type
I had a client with this exact same problem late last year, turns out it was a faulty keyboard and not software related. I would recommend you check your purchase date, see how the warranty looks in your territory and take it back to Apple for advice and repair/replacement.

It's a known problem with some (but not all) 2018 MacBook Pros:


https://www.reddit.com/r/apple/comments/9isi10/mbp2018_spacebar_double_space_is_this_a_common/
https://www.laptopmag.com/articles/macbook-pro-air-keyboard-problems