Particle annihilation occurs when a particle meets its corresponding antiparticle, converting their mass-energy into two photons.
This is a useful oversimplification. Even electron-positron pairs, which have the cleanest electromagnetic interaction, have a three-photon annihilation mode. I think a good search term is ortho- versus para-positronium, if you want to know more.
However, an up and anti up quark (same for down quark) can combine to form a pion. How can it do both?
The formation of a pion is mediated by the strong interaction, while the formation of photon pairs is mediated by the electromagnetic interaction. Pion formation happens first because the strong interaction is … stronger … than electromagnetism. Neutral pions decay to photons because there isn't any lower-mass strong state available. Heavier mesons prefer to decay to pions.
Nucleon-antinucleon annihilations almost never end with one photon pair. The most common process is $\rm p\bar p\to 5^\text{-ish}\pi$, and all three pion charge states are generally involved. The neutral pions decay to photons, but the charged pions don't. Why not?
In the approximation that electromagnetism is negligible, the charged pions ($\pi^+=|\rm u\bar d\rangle$ and conjugate) are the same particle as the neutral pion. We say that they are related by "a rotation in isotopic spin," or "isospin," and in that model they are as closely related as the two regular-spin states of an electron. But the charged pions can't annihilate via electromagnetism, because in electromagnetism we can no longer neglect charge. Charged pions must decay by the weak interaction. Charged pions therefore live much longer than neutral pions, because the weak interaction is … weaker … than electromagnetism.
The charged pion decay is mostly $\pi^+\to\mu^+\nu_\mu\to\rm e^+\nu_e\nu_\mu$, so proton-antiproton annihilation almost always has some neutrinos in its final state.
It's possible in principle for a neutral pion to decay weakly as well, but I believe there's no direct experimental evidence for it. About 1% of neutral pion decays have at least one $\rm e^+e^-$ pair in the final state, but that's permitted by the electromagnetic interaction. Searches for $\pi^0\to\text{invisible}$ decays, including the purely weak-interaction $\pi^0\to\nu\bar\nu$ decays, suggest that these processes contribute below the part-per-billion level.
Is the decay of the neutral pion an example or method of pair production?
Generally when we say "pair production," we mean electron-positron production. Quark-antiquark pairs — at least for the up, down, charm, and strange flavors — don't act like separable particles; they act like mesons. We also don't use "pair production" to describe photon pairs, because (unlike quarks and leptons) there is no conservation law preventing the production of single photons.