It sounds like your question stems from viewing the process as involving several things: all unused space being available for other use, and writing a file the same name as an existing file is being written to the same location. Both of these premises are inaccurate. Also, you talk about the space no longer used being freed. The way it works, those terms are kind of synonymous; space is either allocated to a file or it isn't.
As davidgo described, drives work in whole sectors or blocks. I'll just refer to the space allocation units as "blocks" to keep it simple. Space is allocated in whole block units. A 1-byte file is allocated the entire block, so if you're discussing tiny files, anything under a block in size is still assigned an entire block. Small (sub-block) files have unused space in the block that is not accessible for another purpose. You could talk about a large file that uses multiple blocks being replaced by a smaller file that uses fewer blocks. In that case, there are whole blocks that are no longer needed.
The old file isn't really overwritten. The new file gets saved in another location, using as many blocks as it needs. The reference in the filesystem's file table to the old file's blocks gets modified. Those blocks become unassigned to any file and available for reuse. The old file's content doesn't get deleted as part of this process, it is just ignored until the space is needed. That's why you're able to recover deleted files.
You asked whether this would be different if using dd. dd can be used in a lot of ways. If you limit the discussion to simply writing a new file using the same name, that would work the same way.