You may select both and Pathfinder>Minus Front (Subtract from Shape Area in earlier versions where you should hold down Alt/Option to expand and avoid a compound path consisting of the two boxes), then ungroup.
Or select both and Pathfinder>Divide, then ungroup and remove the three unwanted boxes.
The easier way of doing this is to make one thinner black rectangle then holding down the option and shift key while using the selection tool (black Arrow) drag the left or right or up or down depending on the orientation that will both duplicate the rectangle filled path (box) and keep the alignment
If you select and drag an object while holding the option key it duplicates it, if you hold the shift key while dragging and object it will constrain its movement to 90º, 180º or 45º depending on how you drag. Holding the option shift keys duplicates and constrains the movement.
However you can use the pathfinder as well using the second icon on the top minus front as well.