How is it decided?
Hello and Welcome @Helderda75
First the decisions around pokestops and gyms is outside of Wayfarer and is a Pokemon Go Team decision.
It is fairly complex.
First read this
[A Comprehensive Guide to S2 Cells and Pokémon GO | Pokémon GO Hub]
(https://pokemongohub.net/post/article/comprehensive-guide-s2-cells-pokemon-go/)
Note the that S2 Level 14 cells are key for Gyms
a gym is created when you reach 2 pokestops in a L14 - one of the 2 becomes a gym. you get another at 6 and a final 3rd at 20
2 gives 1 stop and 1 gym in total
6 gives 4 stops and 2 gyms in total
20 gives 17 stops and 3 gyms in total
A showcase stop cannot become a gym
This is all done by a computer algorithm that the PoGo tem decided, looking at the data base of wayspots and deciding which to select and if a gym will be created.
As well as gym creation the article covers pokestop selection at Level 17 cells do read and understand that.