Because your original source footage is already compressed, possibly by 40% = 60% IQ (Image quality)
While you are editing, the file is decompressed (opened/unpacked). If you then ramp up the IQ to 100% then zero compression is applied when re encoding. Hence the file is bigger.
So using 40% compression again (60% IQ) will ‘repack’ the file to a similar size.
This is the same as say an image file, you can save it without compression (100% IQ) or save it with some compression, the former being larger.