Why is the current the same after passing through a resistor even when the drift velocity goes down? A resistor converts some of the electrical energy into heat energy, implying that the energy goes down, implying that the force with which an electron moves, and consequently, the drift velocity goes down.
Now, I=naeV where V is the drift velocity, so shouldn't the current go down after an electron has passed through a resistor?
I am familiar with the pipe-water-flow analogy, but my issue with that is it just involves water flowing, not the loss of any energy from that water.
Where am I going wrong?
This is with reference to steady state.
 A: Electrons are accelerated by the electric field, but slowed down by scattering with impurities, phonons, and other electrons. The velocity that enters the equation $I=nAeV$ is so-called drift velocity, i.e., the average velocity when both the acceleration of electrons by the field and their slowing down by collisions are accounted for. An analogy here is falling of an object with the constant speed, because it is slowered down by the friction against the air. This analogy is rather imperfect, but it serves as a basis of a very well known model of electric resistance.
Remark: The question also seems to confuse the steady state current, where the current is the same in all the cross-section in the circuit, and a transient regime - as could take place, e.g., when the switch has been just closed and the current in different parts of the circuit is different. During such a transient regime there may be regions in the circuit where the charge accumulates or becomes depleted, until the additional electric field created by this charge assures that the current is the same everywhere.
A: 
A resistor converts some of the electrical energy into heat energy,
implying that the energy goes down,

Energy of the charge does not go down in the resistor. That's because electrons alternatively gain kinetic energy from the source of the electric field, while simultaneously giving up an equal amount of kinetic energy when colliding with the particles of the resistor, that is eventually dissipated as heat.

Now, I=naeV where V is the drift velocity, so shouldn't the current
go down after an electron has passed through a resistor?

No. current must be constant in a given resistor or series resistance circuit for conservation of charge. What can vary is the drift velocity $V$ if the cross sectional area $a$ varies in the resistor. In order for the number of charges crossing an area to be constant (constant current), the rate at which charges cross the area (drift velocity) must increase for smaller areas and decrease for larger areas.
Hope this helps.
A: The pipe-water-flow analogy DOES involve energy loss, namely the hydro- or aero-dynamic drag. There are no friction-less pipes. A friction-less pipe would be like a superconductor, but there are none, unless you have a superfluid. There is always viscosity and sometimes turbulence. The thinner the pipe, the larger the friction losses will be, because the flow will be faster for a given flow-rate (which is constant due to incompressibility).
You always have to force the flow through a pipe by some pressure gradient (potential drop on the wire or resistor / voltage). The pressure does work, but that is balanced by the viscous or turbulent friction and the velocity stays the same in stationary flow and so the flow rate (current) stays the same.
A: 
A resistor converts some of the electrical energy into heat energy, implying that the energy goes down, implying that the force with which an electron moves, and consequently, the drift velocity goes down.

Some of the potential energy goes down.  Kinetic energy stays the same.
You could make the same argument about a skydiver.  The diver is converting some gravitational potential energy into heat energy, implying that they are falling slower over time.  But this isn't true.
In both cases, the potential energy loss exactly equals the heat produced.
A: To answer, we must first start with how the electrons move in a circuit. To see this, we only need one concept: charge conservation.
Charge conservation says that if the number of electrons is decreasing in a given region it is because some of them are moving out of that region. This principle allows us to deduce that the current is approximately the same in everywhere in the wire (if the wire is a homogenous material).
To see this, imagine if it wasn't and that the electrons would slow down when passing through the resistor. Since the resistor is not accumulating any charge, the current density incoming should equal outgoing current density. Therefore, the speed at which electrons enter is the speed at which electrons flow out of the resistor.
Now this poses another question: If resistors are supposed to be dissipating energy and it is not coming from electrons, where does the energy come from? The response is quite detailed, but the energy dissipated is actually coming from the electric and magnetic fields inside the circuit. They are the ones carrying energy and dissipated through the resistor.
Veritasium made a very approachable video about this subject and I recommend you watch it to understand better the energy transport mechanism in a circuit.
A: If the velocity of the electrons depends on the position then that automatically means charges are bunching up or becoming more spread out. As can be seen here:

The velocity becomes slower towards the right and this means the density of electrons increases towards the right: the spacing between electrons becomes smaller. In this case the velocity becomes zero at $x=0$ and this means all electrons will eventually bunch up. In electrical wires this increase in density is impossible. Well, it is not actually impossible but an increase in a certain portion of wire can only be temporary. Increasing the density means increasing repulsion which decreases the density. After everything has settled (has reached steady state) the velocity should be equal everywhere in a series circuit.
To see how this equilibrium is achieved consider the following water analogy that has not yet reached steady state. The two dams form two resistors. The voltage over the resistors is proportional to the difference in water height before and after the dam. The water height is proportional to the potential energy per water mass and so it is a good analogy for the voltage. The resistance is proportional to the resistance of the pipe. I chose the two resistances to be equal. The current is represented by the amount of water that flows through the pipe every second. In the graphic below equilibrium has not been reached: we expect $U_1=U_2$ and $I_1=I_2$ since the resistances are equal. Right now $U_2>U_1$ so the pressure in the second pipe is higher and more water flows through the second dam compared to the first dam, i.e. $I_2>I_1$ since $I=\frac{U}R$. This means the water level in the middle section will lower until $I_2=I_1$. In a series circuit having equal current everywhere always happens in equilibrium. Quick note: the water level all the way to the left and to the right is kept constant by a battery.

A: The current in the resistor is constant at every point, and so the drift velocity at every point is inversely proportional to the cross-sectional area.
There is a voltage gradient, i.e., an electric field, along the resistor that replenishes the kinetic energy lost through electron collisions.
