How to merge two partitions
You probably won't be able to merge them directly due to the present of BOOTCAMP partition in between.

I had a very similar issue while I had a "Recovery HD" partition created by OSX10.12 long time ago. Despite I can see the "free space" on the partition map, I cannot resize the Container1 to include it (I can only include it into the Recovery HD partition)

After hours of trial-and-error, I finally solved the problem by removing the "Recovery HD" partition and then I can have all disk space (except the tiny EFI partition) in Container1. And all these can be done through Disk Utility (in partition panel, by clicking + and -), no need to type commands in Terminal.

Try it, hope it works for you too.

BTW, in your case removing BOOTCAMP partition directly might be dangerous, consider using BootCamp Assistant to remove it.