The behaviour needs to change. In the first instance, that must be through regulation and for riders and suppliers to be liable for the consequences of their actions, which sadly are sometimes serious.
That's the crux of it — genuine accountability, not least for the suppliers of street-illegal machines.
It's clear that all too many folks the world over operate on a simple ethic: What's right is what you can get away with. To keep it clean, I'll call them "yahoos" for short.
Put any kind of power into the yahoos' hands — electrical, military, political, religious — and you can be sure that they'll make problems for everyone else sooner or later. Because in their minds, they have only rights — no responsibilities attached.
The only effective counter to that is to whittle away at the things they can reasonably expect to get away with. That's finally sunk in here in California, where ebike adoption's been very high.
Statewide and local ebike regulation here has increasingly turned (a) to the supply side of the problem, (b) to getting existing e-motos and other street-illegal machines off public infrastructure, (c) to making enforcement on the ground easier and more likely to stick, (d) to holding parents accountable for their kids' irresponsible behavior in public, and (e) to get kids trained up for responsible ebiking (since their parents have utterly failed at it).
Meanwhile, the regulators here generally seem committed to preserving legal ebiking on public infrastructure. And to that end, they've been shoring up the 3-class definition of what constitutes a legal ebike in California to make it more enforceable. Not perfect, but a decent place to start against an unprecedented problem that can no longer be ignored — thanks largely to the yahoos.
Keep in mind that the goal of any legal ebike definition is to identify machines that ARE and ARE NOT reasonably safe to let loose on public infrastructure without licenses, registration, and insurance (all of which are ultimately accountability measures).