Insurance is a personal contract: it insures a person's interest, not the thing itself. The insurer chose to insure this owner, so moving the policy to a new owner (assignment) generally needs the insurer's consent. The California standard fire policy (§2071), for example, requires the insurer's written consent to an assignment.
Ins. Code §305: the mere transfer of the insured property does not transfer the insurance. It suspends the insurance until the same person owns both the policy and the property. Example: Mei sells her insured warehouse to Victor without assigning the policy. The policy does not pass to Victor.
Two exceptions:
§303: when the insured dies and the property passes by will or succession, the insurance passes to the person who takes the property. No consent is needed.
§304: a transfer of interest from one jointly insured partner or joint owner to another does not avoid the insurance, even if the policy says coverage ends on a sale.
After a loss, things change. Under §520, an agreement made before a loss not to transfer the insured's claim after the loss is void. The insured is then transferring a claim for money, which does not change the insurer's risk.