In German, most prepositions are followed by a noun in a specific case. For the group of prepositions mit, nach, von, zu, aus, bei, seit, gegenüber, außer, the noun that follows takes the dative case. For example: Mit dem Haus (das Haus), Bei meiner Schwester (die Schwester) and von dem Mann (der Mann).
In the case of the group of prepositions: in, an, auf, hinter, unter, über, neben, zwischen, vor, these prepositions will take either a dative, or an accusative case depending on the specific circumstance of the context. If the preposition is being used to describe the location of the noun then the noun will be in the dative case. For example: 'sie war in dem Haus', 'Es steht unter dem Tisch'
However, if the preposition is being used to express movement from one place to another, 'into the house', 'onto the table' or moving 'in front of the car' then the accusative case is used instead. For example: 'Sie ging in DAS Haus', 'er ging vor SEINE Schwester'
The case of the noun depends on the preposition and whether or not there is movement. These, sadly, are both things that must just be learnt.