Did it start with Snidley Whiplash in Dudley Do-Right, or was that a parody of a pre-existing trope?
Actually it's quite a bit older than that! The trope comes from melodrama, which in its original usage was a kind of lively, popular (as opposed to art) theater that was widespread in the 19th century. These plays emphasized spectacle, dualistic morality, narrative twists, and emotionality – the latter enhanced by melodrama's signature use of orchestral music (thus the melo-). More relevant to your question, though, is the prevalence of spectacle. In the years before cinema, melodrama was the place to see big over-the-top special effects and (live) action. Some of the more elaborate productions featured things like huge casts of extras (like 100s of people on stage at a time), trained animal fights, real fires, and actual functional locomotives. The "girl tied to the tracks" came out of that. Unsurprisingly, melodrama was one of the biggest sources for the cinema, particularly in the period of "narrative integration," from roughly 1905-1915, and the serial shorts of the 1910s and 20s. By this period the train track thing would already have been a hoary cliché. Check out 1917's Teddy at the Throttle, for example, to see it reworked as comedy (around the 20 minute mark).
Parenthetically, scholars like Linda Williams have gone even further and claimed that melodrama as "mode" (rather than genre) underpins pretty much all of Hollywood cinema. Just think of any given superhero movie: you've got good battling evil, spectacular special effects, music bolstering every emotional beat, last minute rescues and shocking revelations, etc. etc. That's melodrama!
Check out Ben Singer's Melodrama and Modernity for more. For Williams' ideas, try "Melodrama Revised." Peter Brooks Melodramatic Imagination, though more interested in novels, is another key work in the field.
An earlier thread, led by u/AshkenazeeYankee, that touches on this same topic and traces the trope back to an 1867 melodrama, can be read here.