Work done in irreversible process can be written as =P (external)(V2-V1). Here P(external) is the final pressure attained by the gas and V2=Final Volume V1=Initial Volume. Then all it depends on is the final and initial state of the system. Then why it is not a state function?
A state function or property is one that does not depend on the path between two equilibrium states. Examples are internal energy, entropy, temperature, volume, and pressure. As far as the system is concerned, it doesn’t matter if the process between the two states is reversible or irreversible.
A path function is one that depends on the path between two equilibrium states. Work and heat are path functions.
As @Aaron Stevens pointed out, work (in this case boundary work) is given by
For equilibrium state 1 you need to provide the pressure. Lets assume it is $p_1$ so for two equilibrium states 1 and 2 we have $p_1$, $V_1$ and $p_2$, $V_2$. There are an infinite number of paths that exists between states 1 and 2, and work will depend on which path is taken, though they all wind up with the final same pressure and volume.
For example, you can take a constant pressure path to get to the final volume, followed by a constant volume path to get to the final pressure. See left diagram below.
Or you can start with a constant volume path to get to the final pressure, followed by a constant pressure path to get to the final volume. See right diagram below.
The work done in each case, the integral previously given, will be the area under each path. More work is done for the left path than the right. Therefore, work is a path function, not a state function.
A state function can be calculated entirely from the initial and final state of the system. External pressure is not a property of the system but of the surroundings.
Well, work is never really a state function. Internal energy is. It happens to be the case when there is no friction and you have an adiabatic process that
However, take a process that has friction, for example, which is irreversible. Then the energy at the start and end are the same but we know some energy was lost to friction. This means we had to do extra work to reach the same energy.
The work is a function of the process taken and the energy is a function of the state. The change in energy happens to coincide with the work of the process for reversible adiabatic processes but not for irreversible ones as showcased by the example above.