I am not 100% sure what you are making or how it should look. Two ways come to mind, first would be to break down some extra pallets for the 2x4's then stack the pallets as you like and cut the 2x4 to the right height and put one on each corner of each stack and lag bolt them in or if they will be getting jarred around I may drill and use bolts nuts and washers. Second way would be to find some 2x4 that are 54 to 56" you would need 6 of them, rough cut from a saw mill would be perfect. Stack the pallets with all the open ends facing the same way much like you have except for your top row, they should be 48" so 54" 2x's would have 3" over hang on each end, slide two in the bottom pallet opening and two in the top pallet opening. Now is where it will cost you a few dollars, grab some 1/2" or 5/8" all thread and put down through the holes you will drill in the over hanging 2x's and then some washers and nuts and tighten to sandwich them together. If you have a welder even some 1x1x3/16 angle would work or maybe even some rebar, and then pick up some bolts and hack the heads off and weld to the angle or rebar to make your own way to tighten the pallets together.
In my head this makes sense to me as I typed it out, but things in my head are not always easily understood at times by others.