In California, kicking you out before 30 days and forcing you to live elsewhere isn't illegal, even if the motel has a policy of doing so.
What is illegal is pretending to kick you out, and then providing you with a room at the same motel again immediately afterwards, so it looks like you've stayed there for less than 30 days, when you've really lived there for more than 30 days. The California Civil Code Section to that effect is Section 1940.1. This statute states (emphasis added):
(a) No person may require an occupant of a residential hotel, as
defined in Section 50519 of the Health and Safety Code, to move, or to
check out and reregister, before the expiration of 30 days occupancy
if a purpose is to have that occupant maintain transient occupancy status pursuant to paragraph (1) of subdivision (b) of Section 1940.
Evidence that an occupant was required to check out and reregister
shall create a rebuttable presumption, which shall affect solely the
burden of producing evidence, of the purpose referred to in this
subdivision.
(b) In addition to any remedies provided by local ordinance, any
violation of subdivision (a) is punishable by a civil penalty of five
hundred dollars ($500). In any action brought pursuant to this
section, the prevailing party shall be entitled to reasonable
attorney’s fees.
(c) Nothing in this section shall prevent a local governing body from
establishing inspection authority or reporting or recordkeeping
requirements to ensure compliance with this section.
A false premise in the question is that:
this de facto means anyone who stays at a motel for 30 days becomes a
permanent resident that cannot be evicted.
This is not true. After the 30 days, you can still be evicted, but the motel has to conduct the eviction through the court eviction process which is slower and more expensive. The entire benefit of the 30 day rule is that you must be evicted to be kicked out of the premises for non-payment of rent.
Before then, they can tell you to leave without a court eviction order and can secure law enforcement assistance in doing so in most cases. The Los Angeles County Police Department policy clarifies this point.