Why close the barn door after the horse is gone?

1. What use is it to spend time to prevent a problem that has already happened?