Prepositions with Dativ
After aus, bei, mit, nach, seit, von, zu the noun goes into Dativ.
A German preposition usually fixes the case of the noun after it: mit takes Dativ (dative), für takes Akkusativ (accusative), and in, auf, an and a few others switch between the two depending on location or direction. The full reference of prepositions with their cases is at /en/prepositions/.
Not just examples, but what to notice in them.
After aus, bei, mit, nach, seit, von, zu the noun goes into Dativ.
After durch, für, gegen, ohne, um the noun goes into Akkusativ.
in, an, auf, über, unter, vor, hinter, neben, zwischen are the Wechselpräpositionen (two-way prepositions). They change case: where? Dativ, where to? Akkusativ.
The places where the rule most often goes wrong in a real sentence.
English "in" covers both "in the kitchen" and "into the kitchen", and "on" does the same for "on" and "onto". German has to choose: a location is Dativ, movement towards a place is Akkusativ.
Ich gehe in der Küche.
Ich gehe in die Küche.
im = in dem, am = an dem, zum = zu dem, zur = zu der. These are not separate rules, just an ordinary Dativ article inside a short form.
With die and das the form looks the same as Nominativ. Check the preposition, not just how the article looks.
Look beyond the translation to the grammatical choice made inside the sentence.
Ich fahre mit dem Bus.
I'm going by bus.
mit always takes Dativ: der Bus -> dem Bus.
Das Geschenk ist für den Bruder.
The present is for my brother.
für takes Akkusativ: der Bruder -> den Bruder.
Das Buch liegt auf dem Tisch.
The book is on the table.
Where is it? This is a location, so Dativ.
Ich lege das Buch auf den Tisch.
I'm putting the book on the table.
Where to? There is a direction, so Akkusativ. English "on the table" is the same in both sentences.
More examples: the same rule in familiar words and short sentences.
A rule sticks once you use it on real words. In Wortkessel you can learn and review them: five exercises, audio and spaced repetition.