Hot take: the frogs make themselves gay when they are in dense proximity. It's a way for them to conserve resources by avoiding sexual competition. This behavior isn't needed on the frontier, where access to mates is largely subject to distance.
I bet the gay frogs croak differently too - coinciding with hormone balance as a feedback loop with environmental resources.
Fun fact: the variation in this behavior is not genetic, but bacterial (and so driven by resource/food availability and stress)