Mark and Matthew were both giving accounts of what they witnessed. They both were present for a lot of Jesus's ministry. They both quoted Jesus and in this icase they both quoted him close enough for the translators to use the same wording.