program works even when hexfile size is greater than flash memory
The hex file contains more than the bytes of the program - it also contains "control" information.

I assume that it looks something like this:

:02000000052ECB
:10000800F000030E83120313A0000A08A1008A015E


Which means that you probably have the "Intel HEX file format".  You can find a lot of references on the net.

Some indications:


The ":" indicates the start of the new line and already indicates it is not a pure hex file (so that mistakes can be avoided).
The first byte (first 2 digits) indicates the kind of line of data it is.
When the line starts with ":10", an address is provided.
At the end of the line there is a checksum.
... - You can easily "google" for the Intel Hex format


This explains why your hex file is bigger - the extra data avoids mistakes.  The format also allows smaller files than the memory you are filling and the data does not need to be contigious.