This is an imitation of the speech of either a small child or a person who suffers from rhotacism (also known, confusingly, as de-rhotacism). This condition is the inability to articulate an 'r' sound.
Very young children often struggle to pronounce 'r' sounds, and a proportion of adults remain unable to do this. The attempt to pronounce an 'r' usually comes out as something like a 'w' sound.
If the speaker is a small child, writing their attempts to say 'trip on a train' as 'twip on a twain' makes them sound cute; if the speaker is an older child or an adult with a speech impediment, the writer is mocking them.