Pokemon games use something called encounter tables. Each area and time of day/season has its own table of the Pokemon that occur. (Sun/Moon even has separate tables for every patch of grass in one area too!)
Each table is made up of several slots, and when you encounter a Pokemon the game chooses a slot at random for the area you're in. But each slot has a different percentage, so some Pokemon appear mroe than others. The slots are the same for every table in a game but they have different Pokemon of different levels in them.
For example, in Sun/Moon there are 10 slots in each table with percentages 20%, 20%, 10%, 10%, 10%, 10%, 10%, 5%, 4%, 1%. If there was only 1 Pokemon in a route then it would have the same thing in all slots. But each slot could have a different level e.g.
Yungoos L2 (20%), Pikipek L2 (20%), Yungoos L3 (10%), Pikipek L3 (10%), Yungoos L2 (10%), Pikipek L2 (10%), Rockruff L2 (10%), Rockruff L2 (5%), Rockruff L2 (4%), Mareanie L3 (1%)
So here you can see Yungoos level 2 has a 30% chance to appear, while Yungoos level 3 has a 20% chance to appear. Same for Pikipek. But most guides just give the overall percentage, e.g. Yungoos level 2-3 has a 40% chance to appear.