How can we replace volume in ideal gas equation with V - nb?
The actual volume occupied by the gas is less than the measured volume(volume of the container).
In reality gaseous particles are not point objects and don't occupy zero space, which is against one of the postulates of the Kinetic Theory of Gases.
Thus while dealing with real gases we have to account for the volume which has been occupied by the gaseous particles. We do so by assuming the volume of gaseous particles to be $nb$.
Now, the ideal volume(actual volume) occupied by the gas is the measured volume(volume of container) minus the volume occupied by the gaseous particles.
Thus, $V_{ideal} = V_{real} - nb$ and not the other way around.
Note, $V_{ideal} =V_{actual}$ and $V_{real} =V_{measured}$.
The mistake you are making is formula you are using and thus
$P_{ideal}(V_{ideal}-nb) ≠ nRT$, but
$P_{ideal}(V_{real}-nb) = nRT$