But also note their main differences:
The collector-emmiter and collector base breakdown voltages vary between BC546 BC547 and 2N3904.
The gain varies between BC546A, B and C.
BC546xx only has a transition frequency of 100MHz, where 2N3904 has an FT of 300MHz.
The gain might not matter for a low gain device such as a buffer amplifier so it'll be alright to use a 2N3904 instead of a BC546C, but not in an audio amplifier which needs a high gain transistor.
The frequency won't matter in a simple light/dark switch so you could use a BC546 instead of a 2N3904, but not in a FM transmitter which needs a higher frequency transistor.
The trick is to understand what characteristics a circuit relies on to work properly - often it will say in the documentation, but check the voltage rating first then the current and maximum power dissipation ratings in circuits that use more power.