It depends largely on the species, anonymous.
Take the combee line, for example. An unfertilized combee egg hatches as a drone combee—or, in other words, a male. However, very occasionally, the vespiquen of the hive will decide that a replacement queen will soon be needed, so she’ll have one of her combee consorts fertilize one of her eggs, thus producing a male. All combee and vespiquen undergo the same process of mating up until the point where the male fertilizes the female; it’s just that in the combee line’s case, the fertilization is more of a conscious effort, rather than the next logical step of the process. The exact same behavior is also apparent in the anorith line, although specimens within these two species face additional issues stemming from the fact that they are “fossil” pokémon. Similar behavior also occurs in the togepi line because the prevalence of males ensures that female togepi survive long enough to become viable breeding partners.
Strangely enough, this behavior is also shown in the snorlax line, although this isn’t because of strategy in colonial distribution but instead because the act of fertilization expends more energy than a snorlax is willing to give up. Consequently, snorlax have evolved to always produce viable eggs; it’s just that unfertilized ones will, likewise, always be male. As for why it’s always males and not females, this is likely a product of adaptation as well: fewer females means fewer clutches. While this could be seen as a means of protecting snorlax food sources (in that fewer eggs means fewer snorlax to feed), it’s actually also a statement of how much energy the snorlax species is willing to expend: it literally takes more energy to lay eggs in the first place than the snorlax are capable of spending.
Conversely, many predominantly female species, including most fairy-types and a few feline pokémon, rely heavily on their female populations to support a colony. Females may breed as well as hunt, build nests, defend the colony, and other essential tasks, while males—though valuable in defending the colony as well—may be seen largely as breeding stock first and foremost. As a result, these species have adapted to produce mostly females to fill these roles. Either that, or in some cases—such as the gothita, luvdisc, clefairy, jigglypuff, and litleo lines—the mother of the clutch is capable of detecting and culling male eggs in order to artificially control the population.
Outside of gender significance to a population, “fossil” pokémon face similar issues to the combee line, where males greatly outnumber the females. In their case, it’s largely because of genetic damage sustained during the resurrection process. In fact, many of the fossils that were initially revived showed signs of originally being female; it’s just that their genetic codes were rendered incomplete. Thus, when mating with another female, it’s more or less a gamble with fossil pokémon. Either the two specimens are capable of combining genetic codes to produce a successful female … or they don’t.
Meanwhile, many of the starters, some fighting-types, relicanth, and eevee are not affected by any of the above but instead by temperature during incubation. If an egg is kept cold (but not cold enough to render it incapable of developing), then the pokémon inside will be able to retain its female sex chromosome long enough to hatch into a female. However, the window of temperature between too cold and too warm for a female tends to be very narrow for these pokémon, and consequently, it’s far, far more likely that the temperature of the egg will be raised high enough to force the fetal pokémon to change its sex chromosomes and, essentially, hatch as a male.
Other lines, such as the abra line, seem to be affected by a variation of this, wherein it’s actually the exposure to psychic radiation that causes the switch, rather than temperature alone.
In short, there are quite a few factors that go into breeding and gender ratios, anonymous, but this should hopefully summarize as many of them as possible.