Your employer has to follow the notice period (Kündigungsfrist). The only way your employer can avoid the notice period is if you are fired for "extraordinary causes" (außerordentlich Kündigung). This is extremely difficult & rare.
Otherwise, the notice period for a normal termination with permanent contract is
2 weeks in Probation Period
4 weeks from the 15th or end of a month
3 months if you agreed to a similar length for your notice period
If you didn't agree to any notice period on your contract, then the legal requirements take over.