Yes, they expire after a while & the lifespan varies across different brokers the most common is 3 months. To prevent your demo account from expiring, you need to login to it regularly. (even if you dont place a trade)
i think they do, i recall my demo account disappearing some time ago and when i contacted support they said it had expired i think it was after 4 months or so. Like @daniel said, if you use it regularly it will stay active. But if it does expire, you can simply open another one and continue practicing. Currently I use TradingView demo account to test strategies but it expires after around 3 months.
Demo accounts are run on a server and these servers can get overloaded when too many accounts are hosted on them. This is part of the reason why unused accounts are yanked off and even active accounts expire after a while.