Bottom
牛 is the ox radical and the indexing radical. Together with the roof above it pictures an ox secured under shelter — a livestock pen. From that came 'firm, secure, fast' and the extension to 'jail/prison' (a pen for people).
亡羊补牢 uses
牢 in the original 'pen' sense.