Gametes are formed by cell division.When a cell is dividing ,it passes on the chromosomes to daughter cells(gametes). The chromosomes passed on have the DNA or genes on it.That is how by passing on the chromosomes to daughter cells DNA(genes) are passed on to gametes. Prior to cell division, DNA replicates with in chromosmes.So replicated DNA is passed on to daughter cells or gametes which is inside the chromosomes.