There are two types of SIM cards: prepaid and postpaid.
Which option works best for you depends on your personal needs. If you want a simple phone with simple features and cheap prices, your best option is a prepaid SIM card.
However, if you need your phone on a daily basis and you would like to have a smartphone cheaper, the best option is a contract with a provider (“postpaid”). With the contract you can also get a phone for a cheaper price (but you can also get a cheap phone second-hand). It is important to know that mobile contracts often have a minimum duration of 24 months and extend automatically if you do not terminate it.
Depending on your situation, getting a contract can be difficult. Usually the providers demand some documents, such as a passport, your residence registration and sometimes a salary certificate. If you don’t speak German, it might be good to ask someone to help with the translation of the contract before signing it, there is often important information in the small print.