This is how it works, in more detail:
What happens with a gametophyte can only be seen under a strong lens, as the gametophyte is small - usually less that half an inch across. The gametophyte has two sets of reproductive organs on its underside - the male parts called the antheridia, and the female parts called the archegonia. The antheridium contains sperm cells while the archegonium contains egg cells. They are each located on the gametophyte, a little separated from each other. If there is a film of moisture, the sperm cells from the antheridium swim towards the egg cells in the archegonium. This may be on the same gametophyte or an adjacent one.
When the sperm cells find the egg cells, they fuse their genetic material to make a cell with the full adult fern set of genes. This cell is the beginning of the adult fern, located in and protected by the gametophyte structure. As it grows to become the sporophyte, it takes over from the gametophyte and becomes the adult fern.
Here is a diagram that shows the fern life cycle.

The diagram is adapted from a more detailed one on the Australian National Botanic Gardens website.
Ferns can reproduce in other ways, too.

It is possible for a sporophyte to grow from the gametophyte without fertilisation, a process known as apogamy. This can happen in drier areas where there is insufficient water to allow normal fertilisation. Ferns can also grow from spreading rhizomes (roots) of existing plants. Brackens often spread this way. Or they can sprout baby ferns at the "proliferous" tips of their fronds. When the parent frond droops and touches the soil, the baby plant takes root on its own. Photo (D) shows a proliferous tip on a Mother Spleenwort fern. It is a faster method that some ferns use to reproduce mature adult plants, in addition to normal reproduction by spores.
Of course, the proliferous baby plant, or the frond that grows from the spreading rhizome, is identical genetically with the plant it sprang from. Only ferns that grow from spores using normal fertilisation can take advantage of the genetic diversity offered by the full reproduction process.What affects where ferns will grow?
There are several factors that adult ferns need to survive (ignoring pests or disease):moisture in the soil; moisture in the air; suitable nutrients in the soil; sufficient light for photosynthesis; suitable temperatures; protection from wind; protection from too much sunlight; protection from freezing; and dependability and continuity of the previous requirements.
Depending on the type of fern, the degree of each factor required can vary greatly.
Another factor that is less often recognised is the difference between the conditions needed for a fern to survive, and the conditions it needs to reproduce. A fern may live quite happily in a relatively hostile environment, but it may not reproduce there. You will only find ferns growing naturally in areas where, at least for some of the time, the conditions suit both survival of the adult plant and reproduction � which means the survival of the gametophyte. Perhaps more than any other factor, it may be the hardiness of the gametophytes that determines whether a fern will thrive naturally in an area or not.Why do ferns grow in some places and not others, and why do some species thrive where others don't?
Like all plants, ferns have evolved to suit their environment. Some can tolerate extreme drought and heat, others only live in the deepest rainforest. You can grow a cactus in the sub-Antarctic, though grasses will survive there. And likewise, you can抰 expect a tree fern to grow in a desert, though some varieties of rock fern do.
Ferns are very successful niche plants: they are well adapted to particular environmental niches - soil moisture, humidity, light, etc. They seldom grow outside these niches, some of which are very specific. For example, in our region, the Mother Spleenwort fern always grows near waterfalls.