As they say on Facebook, "It's complicated." This has to do, somewhat, with one of the more esoteric (and mathematical) aspects of Postscript called a "Winding Rule," which determines what is the "inside" and what is the "outside" of a closed path segment, but mostly with the fact that any path has a direction. You determine the direction by dragging out from top right or bottom left.
There's a discussion about this in the Illustrator Help file under "Compound Paths," which is the only place Illustrator really exposes reversing the direction of a path in the UI. (Ironically, InDesign makes this much simpler. It's in the main menu as
Object > Paths > Reverse Path.)
If you create a compound path, such as by creating outlines for an uppercase letter "B," you can change whether a particular segment is filled or not by selecting it with the Direct Selection Tool and reversing the path via the Attributes panel. In your particular example of a simple rectangle, you can switch from one version to the other using
Object > Transform > Mirror or use the ridiculously complex method (RCM):
Object > Compound Path > Make, open the Attributes panel and turn on
Nonzero Winding and
For a geeks-only technical exposition on the two winding rules, see the Wikipedia entries for Nonzero Rule and Even-Odd Rule, or Google either of those terms.