how can we say that during an irreversible isothermal process, the
temperature of gas remains constant throughout?
As @Chet Miller pointed out in his answer, the term "isothermal", or constant temperature, in connection with an irreversible process refers only to the temperature at the boundary between the system and surroundings, where the surroundings is considered to be an ideal (constant temperature) thermal reservoir. Since there can only be one temperature at a specific location, and given that the temperature of an ideal thermal reservoir at the boundary is considered constant (which in reality is isn't), then so must the temperature of the gas at the boundary be considered constant.
As a practical matter, for want of a better term, one uses the term isothermal for an irreversible process carried out in a constant temperature surroundings to distinguish it from a reversible process carried out in the same constant temperature surroundings. See the figure below.
For the reversible isothermal expansion the external pressure is gradually reduced so that both the pressure and temperature throughout the gas, not just at the boundary with the surroundings, is always in equilibrium with the surroundings.
For the irreversible process the external pressure is suddenly reduced (e.g., suddenly removing a weight from atop a piston) and the gas allowed to expand rapidly (irreversibly) until pressure and temperature equilibrium is reestablished. During the irreversible expansion the temperature and pressure of the gas is only the same as the surroundings at the boundary (pressure because of Newton's 3rd law). Beyond the boundary, however, temperature and pressure gradients exist.
Hope this helps.