The best way to understand Greek prepositions and their objects is
by way of the 'Space-Time continuum', as follows:
1) any preposition showing motion toward a goal or object will take accusative endings (like those of direct object), -ον , etc.
2) any preposition marking 'place where' (X marks the spot, not going anywhere) will take dative endings (like indirect object), -ῳ, etc.
3) any preposition showing motion from or out of source or origin will take genitive endings (like possessive), -ου, etc.
(you may need to juggle font size, under View)
πρός ἐν ἐκ/ ἐξ
------------------------------> X -------------------------->
-ον -ῳ -ου
So, for example, to(ward) the house is
-------------------> Χ ----------------->
πρὸς τὸν οἶκον out of the house is
ἐκ τοῦ οἴκου
In the house is ἐν τῶι οἴκῳ