input: Write a function to add two matrices. The function should first check if the matrices have the same dimensions. If they do not, the function should return the string 'Matrices not compatible'. Otherwise, the function should return the sum of the matrices. The function should handle both rectangular and square matrices.
  
  assert add_matrix([[1, 2], [3, 4]], [[5, 6], [7, 8]])==[[6, 8], [10, 12]]
  assert add_matrix([[1, 2, 3]], [[4, 5, 6]])==[[5, 7, 9]]
  assert add_matrix([[1]], [[2]])==[[3]]
  assert add_matrix([[1, 2], [3, 4]], [[1], [2]])=='Matrices not compatible'
  assert add_matrix([[1, 2, 3], [4, 5, 6]], [[7, 8], [9, 10]])=='Matrices not compatible'
output: def add_matrix(mat1, mat2):
      if len(mat1) != len(mat2) or any(len(row1) != len(row2) for row1, row2 in zip(mat1, mat2)):
          return 'Matrices not compatible'
      return [[mat1[i][j] + mat2[i][j] for j in range(len(mat1[0]))] for i in range(len(mat1))]