If you want to study at a German university, you need a university entrance qualification, ‘Hochschulzugangsberechtigung’ (HZB). This is usually a school-leaving certificate that qualifies you for university studies. If your secondary-school certificate is considered insufficient for studying in Germany, you will have to attend a preparatory/foundation course called Studienkolleg - STK before you apply and enroll in a German university.
A Studienkolleg usually lasts one year (two semesters) and is divided into 4 courses. The courses include German language classes and other subjects depending on your choice of future studies. The German language course is a C1-level course, and passing the STK final exam will provide you with a C1 certificate. You can repeat only one semester.
The final exam, called the Feststellungsprüfung (FSP), has to be taken at the end of the STK. Passing this exam gives you the university entrance qualification. After you complete an STK, you still need to apply to university as an international student. When applying, simply report that you have completed an STK, and continue filling out the relevant information.
You can find more information about Studienkollegs here. The website includes information on the different types of Studienkollegs, application procedures, language requirements, and costs (if applicable). When you are choosing an STK, make sure that the STK is official and state-recognised (whether it is a private or public one), so you can apply to any university.
Depending on the university you want to apply to, one of the following options usually applies for the application:
You fill out the university's application for the degree program of your interest, where there is either a separate section or an extra attachment covering the application to an STK.
You have to submit a different application for STK admission.
The university can either ask you to apply through uni-assist or directly to the university.
One exception is the state of Baden-Württemberg, where you need to apply through the Institute for International Students (ASK) at the University of Applied Sciences Konstanz. More information here.