BMW identifies models by the vehicle badging. The 3 digit car "name" as it appears on the trunklid is a code for the series and the engine displacement of that vehicle.
The first digit represents the series of the vehicle. A 325i would be a 3 series vehicle as a 525i would be a 5 series vehicle. Knowing the series of the vehicle is of use when ordering parts and to identify what chassis it is.
The second and third digits represent the engine displacement of the vehicle. The 325i has a 2.5 liter engine and a 318i has a 1.8 liter engine. The 525i has a 2.5 liter engine and a 535i has a 3.5 liter engine. Note that these digits represent a rounded off number and not an exact engine size. Use the engine identification chart to determine exactly the displacement of the engine in your car.
On the M cars, the badging is different from the standard BMW naming system. The M3 and M5 are limited production vehicles produced by the Motorsport division of BMW AG. The M represents the Motorsport parentage and the 3 or 5 represents the series on which it was based. The M3, based on the E30 3 series vehicle uses an engine based on early BMW Formula 1 efforts. The M5 uses an engine pulled almost directly from the M1 supercar.