Baked 2 cakes simultaneously. One sank in the middle on cooling I have a gas oven. I have raised a question regarding it before, Baking in gas oven does not brown the top. This time when I baked I placed a aluminum foil in bottom rack and baked 2 same size cake on the top rack. The cake on the left baked evenly and was fine. The cake on the right though browned more sank in the middle on cooling.

I had heated the oven to 180 C and baked the left cake for 30 minutes and since it got baked I removed and shifted the cake on the right in the middle as it was wobbly in the center. I baked it for 5 minutes more and then took it out. It looked fine first but when cooled it sank in the middle.
What could have gone wrong here? How can I prevent it?

Thanks!
It sounds like you underbaked the cake to me, the structure hadn't crystallized and therefore couldn't support the weight of the case. Non-fan ovens often have warmer and cooler spots, the cake on the left was likely in a warmer spot than the one on the right, and cooked faster. Or the cake on the left was slightly smaller and cooked faster because of it, either way when you opened the oven door all the heat went out, lengthening the time it would take to finish baking the remaining cake and you just didn't give it enough time. 

Next time test the doneness of the cake using the appropriate method for that cake. I use a spring test and/or an instant read thermometer for most cakes. I don't usually use a toothpick test as I've found it to be inaccurate.