Welcome to Chemistry SE Ainesh.
This is a common doubt that students all over the world have. In order to dispel it, it pays to have a glimpse of exactly what process each equation is describing. The irreversible expansion can be illustrated by the following example.

In this example, the external pressure is the same through out and is lower than the internal pressure. The only thing preventing the achievement of mechanical equilibrium between the two sides is the grey lock. Once the lock is removed, in the second step, the internal pressure is allowed to do work and the gas expands. Notice that from the second to the third step, the external pressure is constant at all times, and it only becomes equal to the internal pressure when equilibrium is reach. hence, when we compute the work exerted by the gas throughout the entire process, like so:
$$
W = - \int_{V_i}^{V_f} P_{ext} \mathrm{d} V
$$
The external pressure, as we have just established, is constant and can leave the integral, leaving us with the familiar expression for irreversible expansion:
$$
W = - P_{ext} \int_{V_i}^{V_f} \mathrm{d} V = - P_{ext} \Delta V
$$
In the reversible expansion we have more like the following situation:

Now here, things are different. The gas is not allowed to expand with its total power against a constant external pressure. Rather, there is an external gas, whose pressure is allowed to lower slowly, allowing the gast to undergo several differential steps of expansion against a constantly dwindling external pressure. At each step in the expansion, the internal and external pressure are in equilibrium, so at each differential step of expansion we have that $P_{ext} = P_{int}$.
If the expanding gas is an ideal gas, then $P_{int} = \frac{n R T}{V}$, which means that $P_{ext} = \frac{n R T}{V}$. Under these conditions we have that:
$$
W = - \int_{V_i}^{V_f} P_{ext} \mathrm{d} V = - \int_{V_i}^{V_f} \frac{n R T}{V} \mathrm{d} V
$$
Now, during this expansion we are assuming that there is no leakage in the internal gas. If this expansion can be made slowly enough and the temperature of the gas is maintained at a constant value throughout, then we can simplify the above expression to:
$$
W = - n R T \int_{V_i}^{V_f}\frac{1}{V}\mathrm{d} V =
- n R T \ln \left(
\frac{V_f}{V_i}
\right)
$$