The internal energy of a system is in general not only a function of temperature. This means that holding the temperature constant does not guarantee that the energy will be constant. The statement that the energy can be expressed as a function of only the temperature applies to the particular case of ideal gases.
Assuming that gases are ideal simplifies expressions for the change in internal energy and enthalpy. For ideal gases at constant temperature and composition ($\Delta T=0$ and $\Delta n=0$):
$$\Delta U = 0\\\Delta H = 0 \tag{1}$$
These expressions are not general. They apply to ideal gases at constant temperature and composition.
In general,
$$\Delta H = \Delta U + \Delta (pV) \tag{2}$$
For an ideal gas at constant temperature, $ \Delta (pV)= \Delta (nRT)= RT\Delta n$
so that
$$\Delta H = \Delta U + RT\Delta n \tag{3}$$
It is also worth remembering that at constant pressure $w=-p \Delta V$ so that equation (2) becomes $\Delta H = q_p$ (in general for any substance, provided p is constant and only pV work is done). But what is $\Delta U$?
We can show from the ideal gas law that it is only a function of T for a constant amount of a pure ideal gas, and, from the kinetic theory of gases, one can also show that for one mole,
$$U_{m,i} = f_iRT$$
where $f_i$ is a constant that depends only on the type of gas (not on thermodynamic variables). Then
$$\Delta U = \sum_i U_{m,i}\Delta n_i = RT \sum_i f_i \Delta n_i $$
for a mixture of ideal gases.