How can I detect if 3 cubes are in a line close to each other like tetris?

Maybe you could use a collider and make it a trigger and see if it is close to other cubes on both sides.

Just a quick suggestion.