ASK ME ABOUT FOOTBALL / STEAM / DEAD CELEBRITIES / THE BLAIR WITCH PROJECT
True, but if you make your megawad for Zdoom (and probably EDGE, maybe other ports too) you can set up any level to follow any other, put your secret levels wherever you like in the sequence, and have as many as you want, by a bit of cunning use of the MAPINFO lump.
That's because it's hard coded in the exe. If you have a secret exit on levels other than 15 and 31, it could produce strange results.
The "strange results" you could get using the other exe's that just have the original doom2 behaviour is that using the secret exit from any regular level will take you to level 31, and the regular exit from 31 will take you to map 16. The secret exit from map 31 will take you to map 32, and the regular exit on map 32 will take you to map 16.
So if you put a secret exit on say, map 01, it will take you to map 31, completing map 31 will take you to map 16, missing out maps 2,3,4,5,6,7,8,9,10,11,12,13,14,15.
If you put a secret exit on say, map 20, it will take you to map 31, completing map 31 will take you back to map16, and you will have to play maps 16,17,18,19 and 20 to get back to where you were before.
This behaviour can be put to good use, although I have only done so using similar behaviour with the doom1 secret levels. eg you could use it to miss out levels to shorten your project, but still finish on map 30, or create a loop of levels for DM. It's probably not what you are looking for though.