I obviously can't speak to every state, but in Indiana there's a state constitutional provision (Art. IV, sect. 5) and laws that describe the process.
The thing about laws is they define lines and what happens when the line is crossed. By describing those lines, it leaves all the conduct on one side of the line legitimate. People are creative. So, they can come up with all sorts of conduct that almost crosses the line, without going over.
The important part of that concept would appear to be that it was enacted by the legislature with the input of the peoples representatives, rather than imposed by a judge (ala Pennsylvania) in what we know is an age in which we know judges are not and not desired to be non-partisan