They are Bipolar Junction Transistor. Both are NPN Transistors. Their difference is manufacturer and hFE and datasheet parameters, seriously. BC547 is European transistor while 2N3904 is American transistor. Both are common NPN bipolar junction transistors used for general-purpose low-power amplifying or switching applications.
The BC548 was released with, and often is found together in datasheets with, the BC547 (higher voltage) and BC549 (lower noise) devices.