How do resistors work? Why is the current before and after a resistor exactly the same? I understand the same amount of charge that enters the resistor leaves, but current is defined to be charge per time. The way I understand it, resistors slow down the speed of electrons, so even though the same amount of charge that enters, leaves, the speed is different, so the current must be different. What is going on here?
 A: Actually the resistor is decreasing the drift velocity because of more collisions and interaction between electrons and the lattice. However, think about what happens if an electron suddenly slows down when entering the resistor. A still faster electron in the wire approaching the resistor will feel the negative charge of the slowed down electron in front of it, which repels the faster electron and slows it down while still being in the wire. Vice versa the faster electron will push the electron in front of it. An equlibrium forms and in summary, the resistor will slow down the drift velocity in the entire circuit.
A: The (average) drift velocity of the electrons is constant because although collisions with the lattice slow them down and change their direction an electric field accelerates them between collisions.
A: If the amount of charge per unit time leaving the resistor were different than the amount of charge per unit time entering it then the resistor would build up a net positive or negative charge over time (think of water flowing into and out of a tank). But it doesn’t. Therefore the amount of charge per unit time entering and leaving the resistor are the same.
A: Let's be quantitative. Assume a 1 kΩ resistor. Apply a current of 1 mA, that is, one millicoulomb per second.. By Ohm's law, that means you have a drop of 1 V. Kirchoff's current law tells you that the current in must equal the current out, except...
When you use Kirchoff's current law, you are implicitly pledging to account for both displacement current and physical current. The connections at the ends of the resistor have capacitance to the environment, ~1 pF for a practical small resistor. So, if you apply 1 V to one end of the resistor, keeping the other end at the potential of the environment (ground), ~1 pC flows into displacement current before the circuit comes to its steady state. That flows into the 1 V end of the the resistor, but it bypasses the grounded end, going directly to the environment.
That's one billionth of the flow per second, and it doesn't continue to flow once the circuit is at a steady state. So, yes, you are right that the resistance causes the current to be different going in and out, but only very briefly. For many circuits, this makes no difference. For microwave circuits, with the current changing on time scales of nanoseconds or less, it's a serious consideration.
A: Imagine a lot of people all walking in the same direction through a hallway that is just wide enough for all the people to walk undisturbed. Now someone will place a restriction in the hallway so less people fit through the hallway at that point. Since less people can fit through, the stream of people has to slow down before passing the obstacle. As a consequence the people walking behind them will also have to slow down. It takes a while to settle but eventually everyone will be walking with the same speed again. The new speed will of course be slower because the obstacle is restricting the flow.
If people would speed up or slow down only at a single point in the hallway it would mean a lot people would bunch up. So the only stable configuration is a constant speed throughout.
Here, the resistor is the same as the obstacle. It will cause the electrons to slow, which means the electrons in the entire wire will slow down. In general for a circuit that is wired in series the current will be the same throughout the entire circuit.
A: 
Why is the current before and after a resistor exactly the same?

For a combination of two reasons.
(1) The electrons flowing into the resistor have nowhere to flow but out of it.
(2) If more electrons were to flow into the resistor than out of it, a negative charge would quickly build up inside. The electrostatic force created by this charge would, in turn, "push backward" against inbound electrons and "push forward" the outbound ones. This would continue until the incoming flow of electrons equaled the outgoing flow again.
The same logic applies, with signs reversed, when fewer electrons flow into than out of the resistor. Either way, "inbound flow equals outbound flow of electrons" is the only stable equilibrium. Temporary deviations from this equilibrium are possible, but they're self-correcting as described in point #2.
I hope that helps.
A: Some teachers use the hydraulic analogy which likens electrons flowing through a wire to water flowing through a pipe. The analogy for a resistor is a narrow orifice or a partially closed valve that makes it harder to pump water through the pipe.
Q: Why is the amount of water flowing out of the valve the same as the amount of water flowing in to the valve?A: It's because there's no place else that the water can go.
It's the same with electrons entering and leaving a resistor. There's no place else that they can go.
A: The OP premise is false. The resistor does not "slow down" the motion of electrons. Actually the drift velocity in some resistors can be tens or hundreds of times higher than in the metallic connecting wires. I cannot see anything that can be said that is going slower in the resistor. On both sides of the resistor the drift velocity is the same if the resistor does not change cross section.Also, is the same in the connecting wires before and after the resistor.
The magnitude of the current density is related to the drift velocity by
$j=n\cdot e\cdot v_d$ where n is the carrier concentration and e is the charge of the carriers (electrons in metals). The difference between different materials is mostly in the carrier concentration as long as we don't have ions that can carry multiple elementary charges. Now, the current is the current density times the cross section of the resistor or wire. So, we cannot assume that we have the same current density all over the circuit. The current will be $I=nev_d A$ and we have two parameters (n and A) that will determine the distribution of the drift velocity in the circuit. But, for example, in a carbon resistor the value of n can be many orders of magnitude lower than in the metal of the connecting wires. So even if the cross section area is larger than that of the wire it is safe to expect that the drift velocity will be much higher in the resistor than in the wires, for the same current.
If the current in the circuit is increased the drift velocity increases in all parts of the circuit by the same factor so it is still larger in the resistor.
A: The velocity of the electrons is irrelevant to the operation of a resistor. The key feature of a resistor is a substantial voltage / current ratio: i.e. it takes energy to shove electrons through the resistor. Different materials & geometries may constrain the electrons in different ways, and may yield different drift velocities.
If a circuit element requires a lot of energy to shove an electron from one end of the element to the other, it will be a "resistor" - regardless of the speed at which the electrons move. The energy input to force the electrons through the material is commonly dissipated as heat:

*

*Hotter metals have a higher resistivity than cool ones, since the electrons (and associated EM waves) scatter off the mobile atoms and the less-regular crystal structure. Different types of materials may have different temperature-dependence.

*A narrow sample of a material will have a higher resistance than a thicker wire: Fine-gauge wires can thus function as resistors or even fuses. The electrons interfere with and repel each other, limiting their motion through the bottleneck.

*Superconductors allow all the electrons to move together as a coordinated whole, without scattering off atoms or each other - but they needn't move at an especially high speed.

*Different materials have different resistivities because their energy bands have different structures in physical and momentum space.

*Magnetic and electric fields can perturb the atomic energy levels, changing the number of electrons which can travel simultaneously in the material without interfering with each other or the atomic lattice.

A: I would say that we should look up the real mechanism of current flow
Here's the brief view
Excess and deficient charges appear to the sides of the wire having connected to the battery ( the wire connected to the positive end will have a positive charge gradient )
Now the battery does continuous work to maintain these potential difference
We know that drift velocity is constant in a given circuit so there must be more charge gradient (potential gradient to set up electric field) near the resistor so the electric field intensity is more near the resistor so more number of electrons will enter the cross-section of resistor per second causing charge coming out of resistor still same
