And yes, there's something called collateral damage, which depends on the situation is considered legal, so yes, if you actually target a military target and happen to also hit civilians that reside in that target it is not a war crime. But it is a war crime if you just generally lob rockets in a direction hoping to hit something.
We also know for a fact that the top Hezbollah commander had such a pager (since it was reported he was in the hospital for treatment), which is pretty strong evidence they didn't exactly hand them out to random people on the street.
Now, can we know for sure without actually knowing what IDF knew? probably not, but it seems extremely likely based on what we do know that the pagers weren't carried by off duty low level grunts (again, top commander had it, iranian ambassador had one or was in close proximity, 90 or so Iranians had one and were flown back to Iran for treatment), but I guess those were just random iranian tourists that happened to be at the wrong place and the wrong time? right?
And feel free to educate yourself further or the law: https://www.icrc.org/sites/default/files/external/doc/en/ass...