In addition to a contract with which the apartment is acquired (e.g. purchase contract or gift contract), the registration of the ownership right in the land register (the so-called "Einverleibung") is required.
Only in exceptional cases do you become the owner without being entered in the land register, e.g. if you inherit a property.