They know how much money it takes to recruit me, what they're willing to spend to retain me, how much money they make for every hour I work. If a contract ends they will lose no sleep over the fact that I am no longer employed.
It makes no sense to show them more loyalty than they show me. So I have to manage my own career. I can't change roles so often than it's not worth hiring me. But I have seen time and again that companies penalize loyalty. Employees who stay get paid less and are pigeonholed in the same roles. In today's world you have to be ready to move when the right opportunity comes along.