The rule of thumb I use is this (and to my knowledge, it's not a widespread rule, but I think it works): if the TOP of the rear hatch is roughly where the BOTTOM of the rear windshield would be on the sedan version (or further forward), it's a hatch. If the top of the hatch is significantly further back from where the BOTTOM of the rear windshield would be on the sedan, it's a wagon. In other words, if you're in the cargo area and you look straight upward, you see a metal roof in a wagon and glass in a hatchback.
I call the Impreza five-door a hatch and the Legacy five-door a wagon.