Under the law, the onus is on livestock owners, or the person in charge of them, to ensure they did not wander, Mr van Barneveld said.
When trains were damaged, costs could be recovered from farmers.
"Not only can it cost the farmer, who can lose several expensive animals, but they can then be liable for KiwiRail's costs, which can also be substantial."
He said one recent incident in the Wairarapa involved cattle getting onto the tracks by pushing against an old wooden gate, which had become rotten, and breaking it down.
An early morning freight train then hit the cattle, killing two and injuring others. Police had to kill one animal due to its injuries.
The collision closed the track, because the train was damaged and needed repairs and the track had to be inspected.
"This cancelled commuter trains from the Wairarapa, forcing hundreds of people on to buses, delaying their arrival at work."
The cost to KiwiRail was in the tens of thousands of dollars, Mr van Barneveld said.
- NZPA