Close the stable door after the horse has bolted
To attempt to prevent a problem that has already occurred; to design and implement a preventive mechanism too late (after the first failure instead of before).
The origin of the idiom "close the stable door after the horse has bolted" goes back to a time when horses were a valuable asset and were kept in stables or barns. If a horse were to escape, it would be difficult to catch, and it would be too late to try to prevent it from happening once the horse had already bolted or been stolen. Therefore, the idiom implies that it's better to take preventative measures beforehand rather than trying to fix a problem after it has already occurred.
To try to prevent something bad from happening after it has already happened