I've actually found a way to solve this recently. I don't think it's a major issue and there are great pianists who have some degree of collapsing. But fixing this can give you more stability, power and control.
The solution is hard to communicate in words but I'll try anyway:
prerequisites:
1. having your hand and arm behind the playing finger. A finger isolated from the hand will have harder time maintaining structure.
2. nails should be somewhat trimmed, not extremely though.
3. the fingers should 'take' the key, not push it (see this for illustration:
https://www.youtube.com/watch?v=ALDzxU452gA around 34:00) - have your teacher explain it properly.
Now for my 'solution':
Each finger has three places where it can bend and 'take' the key:
1. the one closest to the hand
2. the middle joint
3. the last joint, closest to the tip
When one's finger is collapsing, it means she/he activates only the first two. You need to activate the third, and your finger will not collapse. Think of it as trying to clean some dirt off of the key.
A couple of things to pay attention to:
1. this should be done VERY gently with minimum effort. As soon as you start thinking about this last joint it won't collapse. Don't try to curl your finger, just make sure you send energy to all three points. Stop all effort (or 99% of it) once the sound is produced.
2. this takes some conscious effort at the beginning, so try to isolate it in a specific passage, scale or arpeggio.
You'll see it becomes harder to achieve on black keys, on finger 3 and 4, and closer to the fall board. This is where prerequisite (1) comes into play.
I hope it was somewhat clear.