Variables or arguments on the right side of a command are subject to word spliting by the shell unless quoted. You can try the following demonstration.

touch foo\ bar\ baz
#
ls foo\ bar\ baz
foo bar baz
# or
ls "foo bar baz"
foo bar baz
#
var=foo\ bar\ baz
ls $var
ls: bar: No such file or directory
ls: baz: No such file or directory
ls: foo: No such file or directory
#
ls "$var"
foo bar baz

Quotes can be used to escape spaces when assigning to a variable.

var="abc def ghi"