This sentence is correct:
- He boarded the number 30 bus.
This sentence is also correct:
- He boarded bus number 30.
So your general understanding is correct regarding the definite article as used with cardinal numbers. But that's not what we have in the first sentence. Number 30 in the first example is an adjectival phrase describing the bus, so the refers to the bus, not the number. We are following here the same pattern as with other adjectives: He boarded the red bus; he boarded the dirty bus.
EDIT (further examples to hopefully make the answer clearer)
Compare these sentences:
- I went on a holiday for 4 days.
- On the 4th day of my holiday I went to the museum.
- The 4 day holiday to the beach was a very relaxing time.
- The quick holiday to the beach wasn't nearly long enough.
#1 and #2 illustrate the point that the OP makes. With cardinal numbers, leave out the. ("for the 4 days" would be wrong.) With ordinal numbers, include the. ("On 4th day of my holiday" would also be wrong.)
But #3 and #4 are examples of a completely different issue. in both cases the connects with holiday, not with any numbers that just coincidentally happen to be in a descriptive phrase about that holiday.
For example, I could rewrite sentence #3 like this: "The holiday (which was 4 days long) was very relaxing." The has nothing to do with the number and everything to do with the holiday. Furthermore, 4 in this rewrite now has no article in front of it, as you would expect.