When using a zipper foot, the needle stays in the middle. You position one of the foot’s two grooves over the zipper teeth depending on which side of the zipper tape you are attaching. The grooves locate the zipper tape in the correct position relative to the needle.
For example, in the following pic, the left groove is over the zipper teeth, ready to sew the right edge of the zipper opening. (The “right” edge of the zipper opening is when facing at the garment’s right side. I omitted the fabric for clarity, but the fabric would be right side up with its edge on the left, aligned with the zipper tape’s left edge, under the zipper tape.)
And this is when sewing the other edge, with the zipper teeth of the left zipper tape under the left groove: