Not to get too technical, it's been a while since I've wired anything, but this website is great for layout electrics: https://www.brian-lambert.co.uk/Electrical-Page-2.html
The below image from that site shows a potential issue of shorting as the train crosses the frog if not dealt with correctly: