Most commonly spoken German prepositions take the accusative or dative case (the genitive case is used more often in the written form). Some prepositions, such as bis, durch, für, gegen, je, ohne, um and wider, take only the accusative case. Others, like aus, außer, bei, gegenüber, mit, nach, seit, von and zu, take only the dative case.
There are, however, certain prepositions that can take either the accusative or the dative case, depending on the context: an, auf, hinter, in, neben, über, unter, vor and zwischen. Even experienced German speakers can get it wrong sometimes, so although you've probably learned this before, this may be a good time to review these two-way (or dual) prepositions.
The general rule to remember: if the preposition is dealing with "where" something is in a static sense, it takes the dative case; if it is dealing with motion or destination ("where to" or "what about") in an active sense, then it takes the accusative case.
Der Spiegel hängt an der Wand.
The mirror is hanging on the wall.Play Caption
Since the wall is where the mirror is statically hanging, the feminine noun die Wand takes the dative case in this context.
Sie geh'n an die Arbeit wieder.
They're going to work again. [They're going back to work.]
Caption 29, Der Struwwelpeter - Hans Guck-in-die-LuftPlay Caption
Since work is where they are actively going to, the feminine noun die Arbeit takes the accusative case. Note that the word wieder above has an unusual placement in the sentence; this is because it is part of an old-fashioned poem and needed to rhyme!
Wie war eigentlich das Konzert auf dem Mond?
How was the concert on the moon?
Caption 8, Undertube - Peer erzählt einen WitzPlay Caption
Since where they statically are is on the moon, the masculine noun der Mond takes the dative case.
Wir gehen auf die Straßen.
We're going on the streets.
Caption 34, Blumio - Rappen für gute UnterhaltungPlay Caption
Since their destination is actively towards the streets, the plural feminine noun die Straßen takes the accusative case.
Look on Yabla German for other examples of the two-way prepositions an, auf, hinter, in, neben, über, unter, vor and zwischen and discover the different contexts in which they take the dative or the accusative case.