Well, there’s no point closing the barn door after the horses have escaped. Have you ever heard that phrase? There’s no point in trying to stop something after it has already happened. It must have been a terrible feeling for a farmer or homesteader to wake up one morning and find that their horses (or whatever animal) had bolted overnight. At that point there is no reason for them closing the door behind them while they go out looking for the animals. Those animals were vital not only to the farmer running a profitable farm but also to their very survival so not locking the barn door could be a deadly mistake. The idiom though dates to the Middle Ages in Europe and that should be no surprise since the farm animals were just as vital then as they are today.
So, once the horse has escaped, there is no point in closing the barn door. Better get to work trying to find the horse. Don’t dwell on what has already happened, try to fix it! At the same time it is also a good idea to learn from these mistakes so they do not happen again. If a thief breaks into your house and you don’t have a security system it is probably a pretty good idea to install on. That won’t help recover your property or bring those responsible to justice but it can help prevent it again. The solution to the problem has come too late to fix the original issue but that does not mean you can’t work to prevent it from happening again.
There are other ways to say this like hindsight is 20/20 and being a day late and a dollar short. The phrase can also be reworded for just about any animal from a cow to a pet like a cat or dog.