That is simply a side effect of the heap manager. In the most common case you have pages of size 4096 Byte that the OS is handing to the application. Now the heap manager might allocate multiple elements in there (e.g. there could be 4 different strings placed in there). Now if all allocations inside that page are freed the heap manager will release that page back to the OS. However if only one allocation is still in there (e.g. a string that you still hold onto) then the page will be kept. The heap manager will reuse the free space in such pages, but if it can't find suitable space then it will allocate a new page, leading to the behaviour that you observe.
In good old days, when every byte of the RAM and every CPU clock was precious, you had to keep eye on everyting. That is what is sometimes long, long time ago called:
The art of programming.
Nowadays, with such large amount of GBs, so many GHz and CPU cores, good old manners are just forgotten, or even worst - ignored!
But I'm still thinking on every byte and optimize my code to the point it is the most efficient and keep resource as low as possible. That is also a reason why I'm working nowadays with MCUs without an issue even complex projects many people would say it is impossible to create on specific MCU...
The secret is to stick with good programming habbits all the time.