The s-orbitals have a much greater degree of penetration than the p-orbitals, so they experience the nuclear charge more strongly. This electrostatic attraction is sufficiently greater than the electrostatic repulsion between the two electrons that the ionisation energy increases.
Because the p-orbitals do not penetrate through the s-orbitals to the nucleus as much there is less electrostatic attraction. By placing a second electron in a p-orbital the repulsion is now more significant compared to the attractive force, and the ionisation energy is less than expected.
However, each new element also increases the nuclear charge, which in turn increases the attraction that each electron has to the nucleus. When the next p-orbital becomes doubly occupied this stronger attraction once again dominates, increasing the ionisation energy.