When molecules of any kind of atoms get more energy in them than they had before, they move faster, and we call that “heat”. When the molecules move faster, they hit against each other and bounce apart, and so they end up further apart from each other than they were before. The energy can come from sunshine, or from volcanoes, or from friction, or nuclear fusion, or many other sources.
Things are hot if their molecules are moving quickly, and cold if their molecules are moving more slowly. Temperature is a way of measuring how fast the molecules are moving.
Bill Nye explains about heat
If two things are touching each other, heat will flow from the hotter one to the colder one, unless they are the same temperature. The molecules of the hotter one will slow down, and the molecules of the colder one will speed up, until they are all moving at the same speed, and the two things have the same temperature. For instance, if you put an ice cube in your mouth, your mouth will get colder, and the ice cube will melt.
When molecules are cold, they are not moving very much. Then they are usually very close together, like a crowd of people standing still. But as they heat up and move faster, the molecules begin to bump into each other and bounce off, and then they bump into other molecules. Soon they are farther apart from each other. Because of this, hot things have more space between the molecules than cold things, and the same number of molecules take up more space when they are hot. If you boil water in a pot, it will turn into steam.
Because hot and cold are ways of talking about how fast molecules are moving, and there are so few molecules in space, space really doesn’t have any temperature at all. We think of space as being cold, though, because if you put something made of molecules in space, like yourself for instance, you would get cold as your heat moved away from you, evening out the energy difference between yourself and the space around you.