why does ice melt when heated while eggs become hard?
Are you serious, or is this the lead in to some kind of skit?
Presuming this is a serious enquiry from somebody (for example) trying to help out with homework, it is as summarised in post 4.
Applying heat to an egg induces chemical reactions between its constituents (mainly proteins) which result in the reaction products being solid rather than liquid. When performed in a kitchen this is known as "cooking", when studied in a laboratory it's "chemistry".
Applying heat to ice (ie solid water) increases the energy, but the constituents of ice are just water molecules which are not going to react with anything until the temperature becomes extreme. The energy is in the form of vibration of the molecules, and at sufficient energy (ie temperature) the bonds which hold the water molecules together as a solid are broken, and the water becomes liquid and then gas as the temperature is increased further. In a kitchen this is "defrosting", and in a laboratory it is a phase change from the solid form to the liquid form of water in accordance with thermodynamics.