You’ve stumbled onto a fundamental principle of biological function.
In biochemical systems, one form of this behavior is “allosteric autoinhibition”, which basically means “inhibition by another site” (on the same enzyme)" IIRC, an incomplete form of it is found in phosphofructokinase early in the glycolysis pathway.
You could create such an enzyme by, for example, having two binding sites for a given substrate on an enzyme. The first, with a higher binding affinity, would perform some chemical reaction; the second with a somewhat lower affinity would inhibit the first. The chemical prefers to bind at the first site, and so the reaction increases as those sites fill. Once the first sites are almost all filled, the chemical will start to bind at the second site, which will shut off the reaction.
Many bacteria grow preferentially at warm temperatures, but if the temperature goes past a certain threshold, they quit growing at all, and form spores to ride out unfavorable temperatures. [look up heat shock proteins] Similarly, weak sugar solutions cause many bacteria to eat and reproduce, but as you keep adding sugar, you eventially reach a concentration where many will shut down and form spores.
Similar mechanisms are found in the hormonal control of human ovulatory cycle and other endocrine systems. Even more common in biology are systems where low concentrations of a chemical cause Behavior A, but higher concentrations switch it to Behavior B.
Perhaps the best known colloquial example is backing a dog into a corner. At a low level of threat, it may avoid you, but as the threat becomes very high and imminent, it may attack, even if it could escape instead.
A better example would be (IIRC - and I may not) the effect of CAMP on Dichtyostelium. These slime molds (think: giant amoeba) leave a faint trail of cAMP as they move over the forest floor. If another Dichtyostelium encounters a trail, it will follow it. At sufficiently high concentrations, I believe it triggers the swarming response - thousands of Dictyostelia swarm together, and turn from independent one-celled organisms into something akin to a multicellular organism. The swarm shapes itself into a muchroom-like fruiting body, with individual dictyostelia changing (differentiating) to perform the role of different tissues - root foot, stalk, head, reproductive cells, etc. The reproductive cells then produce spores, and the entire swarm breaks apart and each goes its merry way.