Help with unity
Your pictures show blocks that are not exactly aligned with the columns and rows. That leads to various problems.
when the piece collides with another piece it generates several other pieces and ends up locking the unity
I'm not entirely sure what you mean by that.
Some games in the genre have the pieces remain as blocks, if you clear a row and that leaves blocks with a hole below, the blocks will fall if they can.
Some games in the genre, including the original, have the blocks change form into the row. Once it locks in place the four blocks of the tetromino enter an array for the row they're in and they no longer move individually.
Either way, when the entire row is full the row is removed.
but when the piece collides with another piece it generates several other pieces and ends up locking the unity '-'
When Unity locks up it's almost always because you have an infinite loop or infinite recursion in your code. Step through it in a debugger and you should be able to see where it's looping.
Your OnTriggerEnter2D() is called for both pieces at the same time when they collide.
The spawner then spawns two pieces at the same time which instantly collide again and the cycle keeps repeating.