This is the 6th most frequent German word.
im
"Im" is a contraction of "in dem," meaning "in the" in English.
"Im" is used here to signify a temporal context — "im Sommer" meaning "in summer."
Im Sommer fahren wir gerne ans Meer.
In summer, we like going to the seaside.
Again, "im" is a contraction of "in dem," indicating the location within something, here "Schrank," which is masculine.
Der Schlüssel liegt im Schrank.
The key is in the cupboard.
Here, "im" is a contraction of "in dem" (in the) indicating location. "Garten" (garden) is masculine, hence "dem."