Emergency services were called just after 8am and found the mother and baby were dead.
KiwiRail acting group chief executive David Gordon said the train driver has been put on leave and was being offered counselling and any other support.
"These types of events are deeply traumatic for those involved, and our thoughts are with all those affected," Gordon said.
Shortly after the pair died, several people gathered at the scene and could be seen hugging and comforting each other.
The area was cordoned off while police investigated.
Mothers Matters communications professional Claire Henry said it was highly concerning how prevalent mental health issues were among women who were also finding it harder and harder to get support.
Motherhood was becoming more stressful and the midwife shortage and limited choices available to birthing women was increasingly concerning and could be detrimental to a mother's wellbeing, she said.
Mothers Matter is lobbing the Government to establish a fund that enables women to use the money to support their personal needs such as mental health or physio for pelvic floor issues.
They also wanted women to have better access to birthing facilities of their choice and to have better mental health screening from pregnancy until way after birth.
Henry said the Hamilton train incident was extremely sad and so many stories around women's experiences were going unheard.
"There must have been some red flags there."