In case of gametogenesis (let us talk about spermatogenesis) gametes are formed from meiotic division of Primary spermatocytes.
In Primates Primary spermatocytes are cells that that are formed from mitotic division of B spermatogonia (which is another class of germ cells) which inturn are formed from mitosis of Ap spermatogonia which arise from mitotic division of Ad spermatogonia. Ad spermatogonia are inturn formed from Primordial germ cells (see below for details).
Ad spermatogonia are dark A type spermatogonia, reserve stem cells which occasionally divde to renew itself and Ap spermatogonia are pale A type spermatogonia, renewing stem cells.
Why the testis doesn't run out of germ cells? (adaptation of your key question)
The reserved Ad spermatogonia and renewal of both Ad and Ap spermatogonia are responsible for the continuous cycles of spermatogenesis.
This process starts at puberty and usually continues uninterrupted until death, although a slight decrease can be discerned in the quantity of produced sperm with increase in age. (wikipedia)
The process of spermatogenesis in human:

In non-primates like mice it is little different, the following diagram should explain it:

Note:
- Germ cells are cells that give rise to gametes ( present at any level of gametogenesis).
- Primordial germ cells are embryonic cells that originate from a different location (outside the gonads) and migrate into the gonads during the course of embryonic development to divide into germ cells.
- In females, oogenesis also involve production of germ cells (cells of primary follicles) from PGCs through mitosis but the primary follicles produced is fixed, doesn't increase after birth so at a definite age of 40-45 gametogenesis stops.
Further reading: