How to merge two partitions How do I merge disk0s2 and disk0s4

I followed this thread and at step 3 I get the following error 

Error: -69519: The target disk is too small for this operation, or a gap 
is required in your partition map which is missing or too small, which 
is often caused by an attempt to grow a partition beyond the beginning 
of another partition or beyond the end of partition map usable space
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.