Pathname expansion replaces a word containing * (any string), ? (any one character) or [...] (one character of a set) by the sorted names of the files that match it, a glob; a pattern that matches nothing is left as it is, and names starting with a dot are matched only by a pattern starting with a dot. Word splitting cuts the result of an unquoted variable expansion into several words at spaces, tabs and newlines. Quoting suspends both: between single quotes every character is literal; between double quotes $ still expands variables but no splitting or pathname expansion happens; a backslash makes the next character literal.
~ is expanded with the variables). Quotes act at every step, braces included, and are removed last: that is why "$f" reaches the program as one word with the variable’s value, spaces and all.