Just as English uses contractions to combine two words together, German does the same thing but with different parts of speech. German combines prepositions with definite articles.
Contractions occur when masculine and neuter definite articles in the dative case combine with five prepositions. Notice also that there is only one feminine definite article in the dative case. It forms a contraction with zu.
an dem = am
in dem = im
bei dem = beim
von dem = vom
zu dem = zum
zu der = zur
Neuter definite articles in the accusative case also can form contractions with certain prepositions. In German, an apostrophe is never needed in a contraction.
an das = ans
auf das = aufs
für das = fürs
in das = ins
um das = ums
Although it is perfectly correct to use prepositions and definite articles in their full form, German sounds smoother and more normal with the use of contractions.
correct Sie spielen in dem Garten. They play in the garden.
more normal Sie spielen im Garten