Why does supplying energy makes an electron go away from the nucleus? My question is: the energy of electron is considered to be negative, so when the energy is supplied though  photons the energy of an electron increases (tends toward positive direction) and they get away from the nucleus. Does it mean that it behaves like a proton as it gets away from the nucleus (as proton has a positive charge) or its attraction  becomes less? And why via the action of applying energy does it not become attractive to the nucleus?
 A: The nucleus is positively charged so it attracts electrons. This means that in the point of view of the electron, the nucleus is in a valley and the electron on the mountains surrounding it. If you give him more energy that means it goes higher in the mountains, so further away from the nucleus.
I hope this image of mountain and valley helps!
Your misconception comes from the negative charge of the electron. Since it is attracted by positive charge it has less energy when it is at a higher electrical potential -> don't mess up the electrical potential and the potential energy, there is a minus sign for the electron.
To be really clear: if we have an electrical potential $U(x)$ then this means that an electron has the potential energy $E_{pot}(x) = -e \cdot U(x)$ with $e$ being the elementar charge.
A: There may be some misconceptions about the idea of energy and force at play here. I offer this answer as conceptual alternative that focuses on the idea of "systems".
Energy is a property of a system and its configuration (a collection of parameters that describe the system, also called degrees of freedom). Flow of energy between systems and subsystems corresponds to changes of their configurations.
Individual particles in a system does not have energy (assuming they are stable and unchanging in the context of the system). A collection of particles that interact with each other and move relative to each other do have energy. They have a configuration.
Classically (QM changes these slightly due to e.g. the uncertainty principle):

*

*An isolated stable electron does not have (usable) energy.

*An isolated stable proton does not have (usable) energy.

*But, an electron and a proton that interact with each other forms a system.

*The system has an energy level that corresponds to its current configuration.

*The system is free to transition between configurations that share the same energy level (if there is a "same energy" path to the new configuration).

*The system can interact with another system to do (positive/negative) work on the other system. This will cause a change of configuration in both systems.

The laws of nature govern how work applied to the system causes a change in configuration. Work is done by using forces.
Like the "valley and mountains" analogy Nicolas Schmid stated, in your quantum mechanical system, the electron-proton system is at a high potential energy configuration (state) when the electron is "far away", and it is in a low energy state when the electron is "close" to the proton. An easy way to see this is because you must do work on the system to move the electron away from the proton. An outside system must supply the energy.
If the electron-proton system starts out in a high energy state, in order to reach a low energy state, it needs to give away energy somehow. It can do this by doing work on the electromagnetic field, that is, by emitting photons.
For all we care, these photons can be stored in the electromagnetic field, or the system can be brought in contact with another system so that these photons can do work on the other system via electromagnetic interaction. It doesn't matter.
Similarly, if the electron-proton system is in its lowest energy state, then in order to reach a higher energy state (moving the electron "farther away") we must do work on the system. This can be done photons doing work on the system (the electron "absorbing" the photons) which will allow the system to change its state to a higher energy one.
The idea of "systems" and "subsystems" that can interact and do work on each other is a powerful concept.
P.S. "Work" is the transfer of energy between systems. I have also not mentioned "Heat", the closely related cousin of "Work", but it can be applied to the argument too.
