Class X capacitors are used in across-the-line applications where their failure would not lead to electric shock. Class X safety caps are used between the live wires carrying the incoming AC current. In this position, a capacitor failure should not cause any electrical shock hazards, rather, a capacitor failure between-the-lines would usually cause a fuse or circuit breaker to open.
Class Y capacitors are used in line-to-ground (line bypass) applications where their failure could lead to electric shock if a proper ground connection were lost. The failure of a line-to-ground capacitor would not open any safety fuse. In other words, the failure of a line bypass capacitor could create a 120 volt hot chassis that could give you a potentially fatal shock.
Safety capacitors are grouped into a number of different classes. For X Type capacitors there are class X1, X2 and X3. For Y Type capacitors there is class Y1, Y2, Y3 and Y4.
The only types you will probably see for sale are X1 (impulse tested to 4000 Volts), X2 (tested to 2500 V), Y1 (tested to 8000 V) and Y2 (tested to 5000 V).
Of the above capacitors, type X2 and Y2 are the most popular and the type that you will probably want to use. X2 and Y2 safety capacitors are used in appliances that plug into ordinary household wall outlets, while type X1 and Y1 are for heavy duty industrial use. For example, a type X1 capacitor would be used in an industrial computer or industrial lighting ballast that is connected to a 3-phase line (the main power truck lines within a building).
You could use type X1 and Y1 in your tube electronics if you wanted to, but all you require to meet safety standards is the X2 and Y2. The type 1s will cost you more money and may be more difficult to install due to their larger size.
Are X2 and Y2 capacitors interchangeable? Yes and no! You can safely use an Y2 capacitor in place of an X2 capacitor for an across-the line application, but you should not use an X2 capacitor in place of an Y2 capacitor for a line to ground application. The X2 type would work and remove noise interference, but would not meet line-to-ground safety standards. This is because Y2 capacitors are more robust, take higher test voltages and are designed to open, (rather than short) should a failure occur.