Z is automatically set to zero by OpenGL. If you apply a transformation to a 2D primitive it can still end up behind another 3D primitive. If you apply a uniform scaling matrix to a 2D primitive it stays in the same X-Y plane.
Internally all vertices in OpenGL posses 4 coordinate values, x, y, z and w. When not specified z is set to 0 and w set to 1. If you want to know what the w coordinate is used for read up on homogeneous coordinates. Even if z and w are not in use, hardware is designed to perform math on matrices and vectors with 4 rows/columns/coordinates, so omitting them during vertex specification is done only to reduce memory bandwidth usage.