Well, if you tell Java it can take 16 GiB, it will do so and not wast too much effort in keeping the memory low.
If you give it less maximum it stays in its limits and does garbage collection to stay in the range.
Now if the OS has a shortage of RAM it sees the Java process taking 16 GiB and decides that is too much and kills it.