There could be a few reasons why this would happen. If this happens during cooking, check the oven temperature with an oven thermometer. Incorrect temperature causes a sudden rise and then the cake falls back on itself.  Also, if you’ve opened the oven and the cake gets a sudden rush of cold air when it’s not set, it may fall. If the cake falls after removing from the oven, it means the cake wasn’t properly cooked. Check that the cake is cooked through by inserting a skewer or a thin knife into the center. If it comes out clean, it’s done.