In reality, the sentience-filled train was a toy that Morty purchased for Rick at the Citadel of Ricks, though it became unclear if the Rick and Morty in the train were the same Rick and Morty later shown in the living room.
It was bizarre, but hey, that’s what makes this show so great and keeps it out the gutter, and I mean any kind of gutter.
Rick and Morty broke continuity and destroyed their own marketability, as it were, by praying to Jesus, which helped them escape the Story Train and inevitably showed the audience what was actually happening with the characters.