The law applies to everyone, but in different ways.
A landlord must give a "good" reason to terminate your tenancy if either of these is true:
You are a "month-to-month" tenant for an indefinite amount of time, even if you had a prior written rental agreement.
You are in the middle of a "fixed term" written agreement, which means you and the landlord have agreed to rent for a specific time, like 6 or 12 months, but your landlord wants to evict you in the middle of that term.
A landlord does not need to give a "good" reason to terminate your tenancy if you have had a written rental agreement for multiple 6- to 12- month terms without ever becoming a month-to-month tenant. For example, you have lived for many years in a rental and have renewed your rental agreement every time it came up for renewal.