Hello, and welcome to the forum!
Take all the trains off the track and make sure the transformer lights up properly. Then add back just the locomotive alone and see if it runs, and continues to run. If so, add the tender and try again. Continue running the train adding one car at a time until the problem occurs again. When that happens, the last car is at fault.
If the locomotive alone does not work, or stops after a few minutes, there may be a problem inside the locomotive.
Let us know how you make out.
Larry