ELI5: When cooking food, what decides if something melts, burns or solidifies?

r/

eg. when we fry an egg, it turns into a solid.

when we fry a block of butter, it melts.

when we fry a slice of toast, it burns slightly.

In school, we were told that heating substances always turns a solid into a liquid or a liquid into a gas, but obviously this is not always true. So what decides if something melts, burns or solidifies?