I don't know your situation, but I also discovered in myself a desire to get locked in an institution after I failed to build up the courage to end it like I planed. In my case, I wanted to go to jail. I tried to figure out why I wanted that and I think it had something to do with the following:
1. I wanted to give up responsibility of having to deal with the world. I basically just wanted free housing and food.
2. The whole world is a jail, I am trapped in here, so why not make it official? Some sort of breaking the metaphor or something.
3. I think my subconscious wanted to face the evil of the world (and where to face it better than in jail), because I tried to deny myself the real cruel aspects of mankind so many times it has become a hidden repressed aspect. Repressed memories of bulling and childhood trauma might have also been a motivating factor. Because of a more or less successful adulthood (at least at some point, because now I'm hanging by a thread), I buried all the nasty things I experienced as a child. My subconscious knew how bad people can be, but my conscious still hanged to appearances, so maybe I wanted to unconsciously resolve the conflict, or to see how I can keep a brave mind in a scary situation.
4. I wanted to be punished for not having the courage to commit suicide. I wanted my cowardice exposed and persecuted by the world.
Anyway I am glad (so far) I did not do it.
I know I am stuck with life till the end, I will never have the guts to do it. It makes no sense to kick myself for it. The rational approach is to try to build a life that holds as little pain as possible, until death finds me. There is no reason to seek terrible situations or to make things worse than they are.
Anyway I don't know if any of this applies to you, but I wanted to share just in case.
I wish you as little suffering as possible, my friend.