I wrote "two and three story brick buildings" in a story I'm working on, and Microsoft Word autocorrected it to this: I'm not familiar with the rule for this. Can anyone explain it to me?
They're called suspended hyphens. It's a style issue, naturally, so your house style will settle matters. Chicago Manual 17 sez . . .
I hope you don't mind me pointing out that it should be storey, not story. I know unsolicited corrections are irritating *hides*
"Story" is an accepted variant in the Merriam-Webster dictionary, and I've seen it more often than "storey" in American publications. But you're right that "storey" is the original usage, and probably still more prevalent in UK English and its non-American derivatives.
The idea behind the hyphen is to make it clear what's being counted or modified. In this case, it's the floors, but it could also be the number of buildings, so for clarity you put a hyphen between the number (or other modifier) and the thing being modified. So you're really looking at "two-storey and three-storey", shortened to "two- and three-storey". In this case, the sentence isn't super unclear without the hyphens, but it can be an essential rule in some cases. Like, do you work twenty four-hour shifts at your job, or twenty-four hour shifts? (Look up "compound modifiers" for more discussion)