Why does the temperature remain constant around 0 degrees C and 100 degrees C?

For what? For water when it is freezing or boiling? Or do you have another question in mind?

Sorry, it's for water when it is freezing or boiling.

Think of it this way.
Start with a cup of water. Let's say the water weighs 250 grams. We must extract heat from the water, say at room temperature, to reduce the temperature below that of the room. Suppose we continue extracting heat and we get the temperature to 0o C.
To make water freeze, we must extract 80 additional calories for each gram of water we freeze. So we do that and 1 g of the liquid water (at zero C) turns to ice (at zero C). What happens to the other 249 g water. It stays at 0o C. We extract another 80 calories and we freeze another gram of water. Now we have 2 g ice (both pf them at zero C) and 248 g water (at zero C). We extract another 80 calories of heat and we freeze a third gram of ice. Now we have 3g ice (at 0o and 247 g water (at 0o). It doesn't matter what the temperature is that is doing the freezing. It might be in a freezer with a temperature of -20o C but the water will remain at 0o until each molecule of liquid water is frozen. The ice will be at zero C and the liquid water will be at zero C. When the last molecule of water is frozen, then the freezer can start extracting heat from the ice (now all ice and no water) and will eventually lower the temperature to -20o if that is the temperature of the freezer. The same kind of reasoning explains why the temperature of water will not rise above 100o until all of the water is gone. The only difference is that it requires the addition of 540 calories to change a gram of liquid water to steam. The temperature of the water can't rise above 1000 until all of the water has been changed to steam. At that point, we can start heating the steam and the temperature can go above 100. I hope this helps. Its lengthy but thorough, I think.

Thank you, Dr. Bob!

please tell me the answer in which atmosphere layer a (s) dose the tempereature increase as altitude increse?

You're welcome! I'm glad I could help explain why the temperature remains constant around 0 degrees Celsius and 100 degrees Celsius when water is freezing or boiling. It's because during these phase transitions, energy is either being released or absorbed in order to change the state of water. When water is freezing, heat energy is continuously being extracted from the water until every molecule is frozen. As a result, the temperature of the water remains at 0 degrees Celsius until the freezing process is complete. Similarly, when water is boiling, heat energy is continuously being absorbed by the water until every molecule has converted to steam. The temperature of the water remains at 100 degrees Celsius until all the water has turned into steam. Only then can the temperature of the steam rise above 100 degrees Celsius. I hope this provides a clear explanation!