Punishment, especially selfish punishment, has recently been identified as a potent promoter in sustaining or even enhancing the cooperation among unrelated individuals. However, without other key mechanisms, the first-order social dilemma and second-order social dilemma are still two enduring conundrums in biology and the social sciences even with the presence of punishment. In the present study, we investigate a spatial evolutionary four-strategy prisoner׳s dilemma game model with avoiding mechanism, where the four strategies are cooperation, defection, altruistic and selfish punishment. By introducing the low level of random mutation of strategies, we demonstrate that the presence of selfish punishment with avoiding mechanism can alleviate the two kinds of social dilemmas for various parametrizations. In addition, we propose an extended pair approximation method, whose solutions can essentially estimate the dynamical behaviors and final evolutionary frequencies of the four strategies. At last, considering the analogy between our model and the classical Lotka-Volterra system, we introduce interaction webs based on the spatial replicator dynamics and the transformed payoff matrix to qualitatively characterize the emergent co-exist strategy phases, and its validity are supported by extensive simulations.