2/ When a TEE starts, the hardware measures the exact code and configuration and produces a quote, a report signed by a key that only genuine hardware holds, burned in at manufacture.
A verifier checks that signature back to the chipmaker, then compares the measurement inside the quote to the hash of the code that is supposed to be running.
A match means specific, known code produced that quote inside real hardware. Not a description of it, a check of it.