A compressor can fail for many reasons, such as the refrigerant molecule breaking down because the temperature at the end of compression is too high or because of humidity in the lines. Humidity causes hydrolysis and forms acid that causes oxidisation. This reduces mechanical free play and corrodes the lacquer (epoxy resins) in the electric motor. The windings then become exposed, which creates a short-circuit that causes the refrigerant molecules to break down, raising the acidity of the refrigerant line. Unless you clean the line, this acid remains in it and the new compressor will fail for the same reasons.
It is essential to clean the line with a solvent such as NETTOGAZ GC+ or FACILISOLV to remove the acids and carbonised particles created by the motor "fire" and ensure that your installation works properly.
If a compressor suffers a mechanical failure, the metal particles distributed through the line must be cleaned out in the same way.