Why does pair production of an electron and positron only needs 1 photon whereas their annihilation releases 2 photons? I know that in particle annihilation, for momentum to be conserved, we have to create a minimum of 2 photons moving in the opposite direction.
According to Wikipedia:

Pair production often refers specifically to a photon creating an
electron-positron pair near a nucleus.

My question is not why are 2 photons released during the annihilation of positron and electron, I know that 2 photons are released because there is a need to converse momentum. My question is: why does only one gamma-ray is needed to produce 2 particles, 1 positron and 1 electron?
 A: Annihilation produces two photons, because momentum is a vector quantity, and it needs to be conserved. The only way to do that in the case of annihilation is to have two photons exiting in opposite direction, making the sum of their momenta vectors add up to 0 (in the center of mass frame).

For instance pair creation/annihilation can occur inside an electric field (say, close to a nucleus), or inside a magnetic field, in which case one-photon processes are fully allowed, and quadri-momentum conservation is made possible by the presence of the nucleus and/or the magnetic field.

Why during annihilation of an electron and positron 2 gamma rays are produced instead of 1?
Now in the case of pair production, the only way to do that with one photon is to have a nucleus in the vicinity, where the nucleus will take the recoil, meaning that the nucleus' momentum vector and the photon's momentum vector will add up to 0 (in the center of mass frame). Thus, momentum is always conserved.
A: The words "near a nucleus" are critical here. The electric field around a nucleus is the source of a second (virtual) photon, which is needed to conserve energy and momentum. When there truly is only one photon around (i.e. in a vacuum), pair-production cannot occur.
