2004 to 2009 includes the 4th generation of the Subaru Legacy or 3rd generation of the Subaru Outback. The Outback differs from Legacy with different suspension, ride height and more rugged exterior parts. Legacy is known the Subaru Liberty in Australia .
Both the VIN and model code identity the type of vehicle. Note that vehicles sold inside Japan's domestic market don't have a VIN just a model code. Here's a summary see the factory service manual for full details of the location of specification and serial number labels, engines, transmissions (i.e. 4EAT, 5EAT), types of differential (i.e. LSD, Torsen, Viscous), reduction gear ratio. It also describes factory options packs installed on the vehicle i.e. VDC, cruise, audio, airbags, sunroof, etc…
For full information see the Identification section of the factory service manual (under Resources), the Wikipedia pages referred to above or the Legacy Pic VIN/Chassis search tools.