People do it because they can get away with it. As I have said before, a good start would be to have gate/light/track-activated cameras that store videos of trespassers when the light or gate are activated or a train coming (for non-signaled crossings) which then store the information so the police can regularly (weekly or monthly) check if there were trespassers. If so, those drivers (or vehicle owners) are sent a ticket just like red light cameras. After the third (or whatever) occurrence by that driver or vehicle, the vehicle is seized.
Live video feed would not be required. An modern SD card can hold a LOT of data and, if triggered with a sensor picking up motion along with the light/gate/train, would enable plenty of storage time. Even without a sensor, a lot of recordings can be made.