It's a question of
(1) labeling conventions (what you call x, y and z in the coordinate system defining the position of two bonded atoms)
and
(2) the orientation of the two overlapping orbitals from the bonding atoms
If an overlap maximum occurs on the internuclear axis between the atoms, you call the resulting bonding orbital a "sigma" orbital. If maximum overlap occurs on an axis parallel to the internuclear axis, you call this type of bonding "pi". Either s or p orbitals can form sigma bonding orbitals, but s orbitals generally form sigma orbitals, whereas of the 3 conventional p orbitals, only one has lobes oriented along the internuclear axis (this orbital is usually called $p_z$ because its principal symmetry axis coincides with the internuclear axis, which is also labeled the z axis) and forms sigma bonding orbitals. The remaining two (x and y) form pi orbitals. This is illustrated schematically in the following figure:
(note the AOs don't overlap significantly, focus is on showing their relative orientation and labels)