На обед and на ужин are accusative, not nominative.
Accusative is quite a peculiar case in Russian.
In singular, its forms have merged with nominative for most nouns except those in -а, -я and a couple more exceptions.
In plural, even the nouns which do have a distinct accusative form in singular, lose it to genitive or nominative, depending on whether the noun is animate or not.
Except for a couple of edge cases, nominative cannot be used with prepositions in Russian at all. When you are seeing something that looks like a nominative after a preposition, consult with the declension table and you'll probably find the same form used in some other case.