What happens in the atom when it gets heated or cooled and turns into gas, liquid or solid?
I just want to know how does heat affect an atom.
Let's define temperature to be a measure the kinetic energy of the atom.
A single atom has limited numbers of ways it can store energy. It can translate in X, Y or Z. It can't really rotate (well it does rotate, but it takes so little energy to make it rotate that we can ignore it). It can't vibrate. It does have electronic modes where adding energy can increase the orbits of the electrons.
So let's define a ground state. This is the point at which there is no energy stored in the translational or electronic modes. Since there is zero energy and we defined temperature to be a measure of energy, this state is at 0K or absolute zero.
As we add heat to the atom, the atom begins to translate around. The more heat that is added, the faster the translation. We keep adding heat, it translates faster and faster. There is more kinetic energy, so the temperature is higher. Eventually we add so much energy that now it can go into the electronic modes. Electrons start to move to higher orbits. Eventually we could add so much that they are set free and the atom loses some, or all, of it's electrons.
We can still call the energy stored in the electronic modes as a temperature, but it's not the same as what we are used to. You would now have two temperatures, one translational and one electronic.
The same principles apply to molecules, except those can rotate and vibrate as well.
States of matter
Ultimately, it doesn't make sense to look at an atom as a solid, liquid or gas. It's just an atom. A collection of atoms becomes a solid, liquid or gas. How the atoms move about is kinetic-theory. This theory has differences for solids, liquids and gases and each differs in various ways.
But let's look at how the states change. In a solid, you have a bunch of atoms that can be thought of as masses connected by springs. As heat is added to the system, the atoms begin to vibrate in the lattice of springs. As more heat is added, they vibrate enough to break the springs. This is when the solid begins to melt and turn to a liquid.
Now you have a liquid where the atoms are all moving around but they aren't free to move wherever they want. More heat is added to the system and the atoms begin to translate faster and faster. Eventually they translate fast enough to overcome the forces that are holding them together in a liquid. Now they fly free and are a gas.
So ultimately, heat is energy that makes atoms and molecules move in some way. They may translate, rotate, vibrate, or the electrons may begin moving around depending on how much heat is there and what configuration the molecule has.