a resistor has a certain resistance, which determines the amount of potential energy the electron lose by passing through it. Since the resistance of a single resistor is constant no matter how many resistor you put in series, why does the potential energy lost in a resistor is different if you change the total number of resistors in series.
Resistors do have a resistance, determining the potential energy lost by electrons, but be very clear: that resistance is defined by the $V=IR$ relationship across the resistor.
Thus there is no way to talk about how much energy is lost within a resistor without knowing the voltage difference applied across that resistor.
If you have multiple resistor in series with a battery to generate the voltage potential, the voltage is not controlled by the resistors. It is controlled by the battery. The voltage drop across each resistor is adjusted accordingly, and thus the number of electrons traveling through the circuit.
Let's think about this another way: why is the potential energy lost in a resistor different if you connect it to a different voltage supply?
The answer to both questions (yours and mine) is that energy is conserved. It is not the resistor that determines how much potential energy is available, but it is the power supply. If there is no power supply connected to a resistor, there is no potential energy to be lost by an electron. When you connect a power supply to a resistor, current flows, and the electrical energy added to the system by the supply is transformed by the resistor into internal energy, usually seen as an increase in temperature. If the resistor is a coil of wire in a motor, the energy becomes kinetic in the motor. If the resistor is a filament in a bulb or is part of an LED, the energy becomes photonic.
But the actually potential energy lost by the electron is determined by the supply. A series of resistors will simply distribute the total energy among them. This occurs because the flow of charge will have a smaller rate through each resistor, but the total rate of energy change in the series will be exactly the same as the rate of energy added by the supply.
a resistor has a certain resistance, which determines the amount of potential energy the electron lose by passing through it
No, this isn't correct; the amount of energy lost by electrons on passing through a resistor is determined by the resistance $R$ and the current $I_R$ through which is, loosely speaking, how many electrons are passing through the resistor each second.
Note that the voltage across a resistor is proportional to the current through
$$V_R = RI_R$$
So, if the current through is larger, the voltage across is larger, and thus, the potential energy lost by a charge, in passing through the resistor, is larger.
why does the potential energy lost in a resistor is different if you change the total number of resistors in series.
Because adding additional resistance in series reduces the current through the original resistor and so, from the previous section, reduces the potential energy lost.