They're the ones with the money. They can easily guarantee that you buy the product they want. All they need to do is give you less money, buy the product themselves, and give it to you.
But legally, you are allowed to change insurers at any time. They would probably not be allowed to include that as a contract-breaker clause in the loan itself due to free-market-reasons, or force you to take only their insurance to have the loan (we tend to have a few laws about keeping conflicts of interest like this at arms length but I'm not sure about this case). But if insurance is legally required, I suppose they can ask for proof periodically after you leave to terminate the loan.
It's basically the bank just outsourcing a lot of risk to the insurance company (via the house buyer).