my mac loss about 80GB free space after running diskutil commands

This is a duplicate of a question asked many time before. Perhaps a better explanation is required.

The command sudo diskutil eraseVolume free none disk0s4 preforms at least the following tasks.

  1. Erases enough of disk0s4 to make any volume or container stored in this partition difficult to recover.
  2. Removes the partition associated with disk0s4 from the Guid Partition Table (GPT).
  3. Reorders the remaining partitions is ascending sequential order.
  4. Depending on the version of macOS, either correctly hybrid partitions for BIOS booting Windows installation or removes all hybrid partitioning.

The command does not add the free space back to another partition. To do this you must execute another command.

The sudo diskutil apfs resizeContainer disk0s2 0 will add all the free space immediately following the partition associated with disk0s2 to the container associated with disk0s2, but only if the type is Apple_APFS. In your case the type is Apple_HFS.

The correct command would be sudo diskutil resizeVolume disk0s2 R. This command will add all the free space immediately following the partition associated with disk0s2 to the container associated with disk0s2, but only for certain partition types such as Apple_HFS. If a partition of type Apple_HFS is followed immediately by a Apple_Boot type partition, then the following occurs.

  1. The Apple_Boot type partition contents is moved to the bottom of any free space immediately following this partition.
  2. The Apple_HFS type partition (and the volume it contains) is expanded to include the free space between itself and the Apple_BOOT type partition.

I should note that after using the diskutil command there could still be a small amount of free space between partitions. The macOS operating system has various rules regarding the requirement of this free space which are not worth mentioning.

The diskutil command does not have a way to directly show the free space between partitions in the GPT. A command that can show the free space is called driveinfo, which you can download. This utility is a bash script which uses the diskutil command to determine and display the free space. In your case after downloading, you would need to enter the following command to display the free space.

~/Downloads/driveinfo-1.0.3/driveinfo disk0