Hidden abilities (often just called HAs) were introduced in generation 5 and every generation since has had unique ways of obtaining Pokémon with their HA. First, let's look over all the ways that you can't find Pokémon with their HAs.
Most random encounters
If you're just running around in a patch of grass, most of the time, the Pokémon you encounter will have a 0% chance of having their HAs. There are some specific areas where this isn't the case (all of which are listed below), but the vast majority of the time, you cannot just keep encountering Pokémon until you get a HA one; you have to do something special.
Breeding a Pokémon that doesn't already have its HA
If you want to breed a Pokémon with its HA, you must already have a Pokémon of that evolutionary line with its HA. If the parent isn't of the same evolutionary family as the offspring, then its ability has no impact during breeding. Additionally, when breeding two Pokémon of the same evolutionary line, the male's ability still has no bearing on the offspring; male and genderless Pokémon can only pass down HAs with Ditto. In Gen 5 only, HAs cannot pass down if one of the parents is Ditto, which only allow female Pokémon to pass them down in those games.
Pokémon with HAs can be found through these methods in the corresponding generations:
Generations 1 and 2
Abilities didn’t exist at all in the first two generations, but any Pokémon transferred from the Virtual Console versions of these games to Pokémon Bank will automatically receive its hidden ability, if it has one.
Generations 3 and 4
These generations had abilities, but not hidden abilities, so it's impossible to get any Pokémon with its hidden ability in these games, because they didn’t exist.
- Pokémon Global Link
Any Pokémon found in the Entree Forest (which appear there by interacting with the Pokémon Global Link) will have its HA. Note: this method was shut down several years ago.
- Pokémon Dream Radar (B2W2 only)
Any Pokémon transferred from the Dream Radar to B2W2 will have its HA.
- Hidden Grottos (B2W2 only)
Any Pokémon found in a Hidden Grotto will have its HA.
- Some static encounters
In BW, there is a Musharna in the Dreamyard and a Darmanitan in Desert Resort that are guaranteed to have their HAs. In Black 2, there is a male Jellicent in Undella Bay and a Mandibuzz on Route 4, while White 2 has a female Jellicent and Braviary at those same locations, all with guaranteed HAs.
- Pokémon traded from Yancy/Curtis
After beating the game, all Pokémon received in a trade with Yancy or Curtis will have their HAs.
- Horde battles
Pokémon encountered in a Horde has a chance of having its HA.
- Friend Safari (XY only)
Pokémon in the Friend Safari will have a chance of having their HAs if the friend the safari came from is recognized in both your 3DS's friends list and the PSS friends list.
- DexNav (ORAS only)
After raising the search level of a Pokémon up high enough, it will start having a chance of having its HA.
- SOS chaining
After getting to a chain of 10 Pokémon in an SOS battle, Pokémon will start having a chance of being HA.
- Some totems (USUM only)
The totem Gumshoos, Alolan Marowak, Ribombee, Alolan Raticate, Togedemaru, and Kommo-o you can receive will all have their HAs.
Let's Go Pikachu / Eevee
Like Generations 1 and 2, LGPE don't have abilities. Unlike Gens 1 and 2, Pokémon transferred from these games will never have their HA.
- Max Raid battles
Some Pokémon from Max Raids have a chance of being HA, usually corresponding to higher number of stars. You can check Serebii's list of raid dens to find whether a Pokémon can have its HA. Notably, all Pokémon from rare raids on the Isle of Armor (but not the regular Wild Area) are guaranteed to have their Hidden Abilities.
- Breeding a Pokémon with its HA
We went over cases where breeding won't result in HA Pokémon, but a bred Pokémon will have a 60% chance of being HA if either the female Pokémon or non-Ditto parent has its HA.
Some Pokémon (most commonly legendaries and starters) can't be encountered through any of the methods above, so they're usually given out with their HAs as events if they have one.