We don’t know the precise circumstances of Gregor’s knighting, but two possibilities come into mind: either it was done as a favor to Tywin Lannister, as Gregor was his bannermen, or it happened as a result of Gregor’s prowess during a tourney or melee, which is pretty common.