I have no idea why the original command did not work, yet the second one did since the second command has an incorrect path listed since the spaces are not properly escaped or quoted. The two valid ways of issuing the command is either with the backslashes to escape spaces in the path, or putting quotes around the path.
Apple's example:
sudo /Applications/Install\ macOS\ Mojave.app/Contents/Resources/createinstallmedia --volume /Volumes/MyVolume
Equivalent command using quotes instead of backslashes to handle the spaces within the path:
sudo "/Applications/Install macOS Mojave.app/Contents/Resources/createinstallmedia" --volume /Volumes/MyVolume
It is even possible to only place the quotes in the middle of the path, but that would just make it awkward & confusing, but it is technically possible even if it is bad form.
The only thing I can think of is that you have some kind of customized Bash configuration...what that could be I have no idea since I've never seen anything like it. If it did work, then you do notice that you still had a backslash in the path both for "createinstallmedia" portion just after "Install" and the same for the path to the mounted volume as well.
Personally I would be concerned about your Bash configuration as its behavior is highly unusual.