Model train speed controller issue

You should have reverse biased diodes across the transistors, to conduct the back EMF that you get from inductive loads like train motors.