Legislators who propose and pass this legislation use it to demonstrate their support for Israel, or coal mining, or gun rights, or whatever anti-boycotting cause they're advancing. They are the primary beneficiaries here, because it helps them get donations and get re-elected.
Entities who are forced to sign these pledges generally put as much thought into it as you or I put into agreeing to a TOS with a binding arbitration agreement. In other words, not very much thought at all.
Because ... As you've pointed out, the government cannot, in practice, prove that those entities are actually boycotting unless the entities come right out and say it. So if the entities actually want to boycott Israel, they can continue to do so without announcing it. The law doesn't actually stop anyone from boycotting Israel; at best, it merely stops them from publicizing what they're doing.
The reason this doesn't get much push-back from most people who are forced to sign the pledge is because they weren't actually planning to boycott anyway. But there's a small number, such as the publisher who's at the heart of this case, who had no plans to boycott Israel, but who isn't going to let those legislators bully them.