Part list (besides the printed parts)
4 pcs carpenter pins
2 pcs neodymium magnet cylinder with 10mm diameter and 5mm height
The slots for the magnets are rather tight however I recommend to use glue to make sure the magnets do not fall off. Neodymium magnets swallowed in pair by kids cause very serious trouble.
Use the pins the fit the wheels and put the magnets in the small pockets at each end. Carefully align the poles of the magnets. North shall be outwards on one side and south on the other for smooth connection of wagons.
The wheel is taken from here: https://www.thingiverse.com/thing:87690
print well in PLA.
Though it prints with ABS too, it is too bulky so the shrinking material loses layer adhesion.