As the ammonia has unique vaporisation and condensation property that makes it as refrigerant. In the vapor-compression refrigeration the compressor uses a circulating liquid refrigerant as the medium which absorbs the heat and convert in form of vapour and removes heat from the space to be cooled and subsequently rejects that heat elsewhere.
In this way the liquid ammonia in form of compressed vapor absorb the heat and get vaporises in this way remove the heat from the surrounding and make it cool.