It's the Whyte system of engine classification. Used primarily for steam engines, but also for some electrics.
The first number represents the number of wheels on the lead truck, if any. If there is no lead truck, the number is 0.
The last number is the number of wheels on the trailing truck, if any. If there are none, zero is used.
The middle numbers represent the number of driving wheels. If the engine is articulated, there will be more than one number here.
For example, your 2-8-2 is a Mikado.
A 4-6-4 is a Hudson, while an articualted Challenger would be called a 4-6-6-4.
A switcher, with no leading or trailing truck, would be something like an 0-6-0 ot an 0-8-0.