Laurence's answer was already accepted, and it basically contains the relevant things about this question. But I'd like to try saying it with different words.
I assume that by "working" you mean that the chord sequence feels sensible and likable, and not random or chaotic. And the "why does it work" question means, you'd like to know some kind of a musical pattern (or like Laurence says, "framework") of note and/or chord roles where this chord sequence fits, such that the same pattern can be found in other songs, and such that you can somehow relate the pattern to other patterns you already know. You're not really in need of a cause-and-effect logic explanation, you want to be able to reason and relate, in order to operate with these phenomena and perhaps take them as part of your musical vocabulary.
By "diatonic chord sequences", I assume you mean conventional functional harmony, where chords rooted on the notes of a major or minor scale, numbered as e.g. I II III etc., have certain functions that could be called I / IV / V (or e.g. i / iv / V) or tonic, subdominant, dominant, etc. The mechanics within this pattern (or framework) can be extended to include things like "secondary dominant" or "pre-dominant", so that e.g. in the key of C major, D7 would be a secondary dominant for G7, giving a typical chord progression C - D7 - G7 - C.
This pattern can be though of as a game or theatrical play where the notes and chords are players or actors that have certain roles. For example, C = defender, F = midfielder, G7 = attacker. Actors and roles. If you follow what happens in the game or play, you can quickly identify the roles, the players don't have to yell "I am an attacker!" You can notice or instinctively feel that without anyone explaining it.
That's not the only pattern, and static note roles are not even the only type of pattern. There are other kinds of patterns related to changes i.e. "happenings" that change the behavioral (I don't want to say "functional" because that word has certain very specific meanings) relationships between the notes i.e. what possible roles you perceive each note to have. One such pattern is modulation, which is something that makes you change your perception of which note is "home", and consequently, the roles of all other notes as well. When that happens, the same players are on the playfield, but suddenly they seem to change their formation, and e.g. the player that used to be a defender becomes an attacker. The sense of "where home and everything is" changes.
A sense of modulation takes time and carefully placed notes to be felt to have happened completely. There are different ways to do a modulation, and they have different "settle-in rates". Some modulations are more ambiguous than others, and different listeners have a different sensitivity to it. Ultimately, the key (just like the sense of rhythm - "where is one") is in the ear of the listener, so to speak. It is subjective.
Some harmony tricks particularly in jazz and related types of music work by partly or slowly opening the door for an interpretation that a modulation might be starting to happen. Some harmony tricks, like ones that can be done with symmetric chords like diminished chords, might even open the door to multiple different target keys at the same time. The sense of key is deliberately kept ambiguous, and skillful players can toy around with this sensation. Personally, I like the sense of harmonic ambiguity very much.
One way to see the Ab chord in the Thomas the Tank Engine theme is to see it as a possible start for a modulation. The players on the field start moving so that you think they might change roles ... but then they move back to the old formation. The chord sequence is flirting with different interpretations, and it wants you to anticipate a possible change of note roles. The anticipation in itself is a commonly used musical thing and a pattern. Even though it might not be a part of the functional harmony pattern itself, a modulation is a transition from one functional harmony "layout" to another.
Some people may look at the whole song, take a peek at the last page of the story and say that it wasn't a modulation after all, it didn't really go to any other key... But music happens "now", your brain doesn't really feel what hasn't happened yet. It can anticipate very strongly, and it can extrapolate possible future events, but what happens in the future always remains to be actually experienced.
I encourage you to test this theory. What if the Ab chord could work as a gradual start for a modulation to the key of Eb major or the parallel minor of C major, C minor? Take the Thomas theme and play it up to that point, and then start playing something in Eb major or C minor. Does that work in your opinion? While the Ab chord is playing, what if you play the Eb major scale on it - does that work in your opinion? Or could the Ab chord work as opening the door for a modulation to ... C#m? Try it! After the Ab chord, play a C#m chord, and play a C# minor scale as melody. Does that work? What actually happens in the song is just one possible thing that could have happened. Each chord - and even each individual note - affects the set of harmonic possibilities, "what might happen next". Your question "why does the Ab chord work" could be translated into "how does the Ab chord change the set of harmonic possibilities". As a practical field test for "where did this chord take me harmonically", stop at the weird chord and try playing different notes and scales.
(What comes to the Ab note in the melody, it could also be harmonized using the Barry Harris "sixth diminished" scale and chords, where you only have two chords: e.g. C6 as the tonic, and Ddim7 as the dominant. Try playing C6 for the start, and Ddim7 for the Ab note in the Thomas the Tank Engine theme's melody. I'm sure someone more knowledgeable about jazz harmony theory can come up with an explanation how the Ab major chord is a substitute or somehow related to this Barry Harris dominant.)
One more perspective to the C - Ab chord sequence. It fits a key change between C major and C minor, which has a very specific taste to it, and flirting between parallel major and minor keys is used in a lot of blues/jazz based music.

If you (1) know how to perform this kind of a key-change, and (2) you know what kinds of feelings it produces, and (3) you can identify the pattern when you hear it, and (4) when you see it written down... then you can legitimately say that you understand it. However, if for e.g. some socio-cultural reasons you think that being able to use and recognize the pattern is not enough, and to be an honorable person you also need some sort of theory book references and a fancy theoretical sounding name for it, then OK, fair enough, you can call it a key-change between parallel major and minor keys. Knowing names for things helps communication and thinking.