Seems like the rule is serving as an unofficial (and frankly illegal) town "drawbridge" to keep the riff-raff out.
Edit: to all the replies telling me how it couldn't possibly work because people will break the rules: which is also true of the current system? And gates are a thing, folks. So is automated enforcement?
If it's a private tunnel, nothing stops the railroad from saying "if you ignore the traffic control system, we fine you $x. If you do it again, you're barred from using the tunnel for a month and have a fine of $x*2. If you do it again, you're barred from using the tunnel permanently." Watch how fast people follow the rules.