This question already has an answer here:
In Illustrator how can I merge this roof vector to the background of the square?
As @Bart Arondson has pointed out, what you want to use is a clipping mask.
This is how it works:
You need to group your roof-tiles first. Select all of them with the black selection arrow, and use cmd+G or go to
Then you make sure your square is on top of the roof-tiles group. Pretend this multicoloured pattern is your roof.
Select both roof and box and go to
That should give you this result: