Everything will expire one day, including our Sun. Flight recorders are no exception.
Older flight recorders used magnetic tapes. They used to work like any other tape recorder. At present, solid-state memory boards are used. These are considered much more reliable than magnetic tapes, because no moving parts are involved like magnetic tapes.
Data from both recorders is stored on stacked memory boards inside the crash-survivable memory unit (CSMU). A CSMU is:
... is collectively the solid-state memory chips and a hardened metal
container filled with specially designed heat insulating material. It
is this container that provides the survivability, for it is able to
withstand massive crushing loads, intense heat, and exceptionally high
G forces, all of which is proven by crash survivability testing.
Image Source
You can see that the memory boards are inside stainless steel shell, which is designed to withstand the crash. Although there is a limit of writes on solid state memory, after a crash there are no more writes.
When the FDRs/CVRs are recovered from a crash scene, there are various methods to retrieve data, depending on the condition of flight recorders. This process can take weeks or months to complete.
Further reading: How Black Boxes Work