Short answer: Because there aren’t enough single letters or one-digit numbers for all of them.
Long answer: What is now the NYC subway was built by three (or four, depending on how you look at it) separate organizations, some of which were formed by mergers of existing railroads and trolley lines all over the city. The first underground line in Manhattan was built by the IRT company, and soon after their competition, the BMT, started building lines as well. The BMT built their tunnels wider and their cars longer, so they could not inter-operate with the IRT system. (Although they all used the same standard North American track gauge of four feet eight and a half inches.)
Later, the city-owned IND system was built with the same loading gauges as the BMT, so the two could inter-operate. When the City acquired the IRT and the BMT to run the whole system, the former IRT lines were called “Division A” and the former BMT and IND lines were designated “Division B.” With the completion of the Chrystie Street Connection, Division B can operate as one large system, while Division A remains separate. (Although there are track connections between the two, such as those at Queensboro Plaza.)
The city-run system went through a number of changes in nomenclature and map design, but in the current system, Division A lines use numbers, and Division B lines use letters. (An exception is shuttle lines, always given the designation “S,” even the 42nd Street Shuttle which is really part of the IRT. Internally, that line is actually called #8.)
The colors are determined by which Manhattan trunk line a given train service connects to. (There are also three colors that don’t have Manhattan trunk lines.)
Red: 7th Ave IRT
Green: Lexington Ave IRT
Orange: Sixth Ave IND
Blue: Eighth Ave IND
Yellow: Broadway BMT
Purple: Flushing Line IRT
Gray: Canarsie Line BMT
Light green: Brooklyn-Queens Crosstown IND (this is the only service that doesn’t touch Manhattan.)
Now that you know the Big Secret, you can more easily decipher some things. The reason why the Q changed from orange to yellow, for example, is because the Coney Island/Stillwell Ave line in Brooklyn changed routings due to construction on the Manhattan Bridge, and now connects to the Broadway BMT instead of the Sixth Ave IND in Manhattan.
The 2, 3, 4, and 5, despite being half-green and half-red, all run on the same tracks after Nevins Street in Brooklyn, (and then split again after Franlkin Ave.)
The E, F and G lines all run together on Queens Blvd, but the E and F connect to different lines in Manhattan and the G goes straight to Brooklyn, so they’re different colors.
A letter or number designation is properly called a “service,” although most people will use the terms “line” or “train” even though that’s not entirely accurate. A service is made up of routings on several lines. Some examples:
The Q service:
- Starts at Coney Island in Brooklyn,
- Operates on the Brighton Beach line in Brooklyn,
- Connects to the BMT Broadway line (thus earning its yellow color) via the Manhattan Bridge,
- Terminates at 57th Street in Manhattan.
The B service
- Starts at Brighton Beach in Brooklyn,
- Operates on the same Brighton Beach line as the Q, but on the express tracks instead of the local,
- Connects to the IND Sixth Ave line via the Manhattan Bridge and the Chrystie Street Connection (thus it is orange),
- Connects to the IND Eighth Ave line at Columbus Circle (an oddity),
- Branches off to the IND Concourse Line in the Bronx,
- Terminates at Norwood Ave.