It's the coding. Like lets say There are Pidgey and Rattata
The codings are
3455-7866-8989 (Pidgey)
3455-7866-8980 (Shiny Pidgey)
1178-3462-5760 (Rattata)
1178-3462-5761 (Shiny Rattata)
These codings are fake for the example!!!
Ok, so pidgey is rarer that rattata. Then the coding will be randomly selected like this.
rattata
rattata
rattata
pidgey
rattata
rattata
shiny rattata
pidgey
rattata
pidgey
There is no timer! This is how Pokemon appear. So, you can walk one patch and encounter a wild rattata then turn twice and encounter a wild rattata, then when you are about to exit the huge patch of grass, you can encounter a Pidgey.
Hope this helped!