What do DNS record types like A, CNAME, MX and TXT actually do?
Each record type answers a different question about a domain, which is why a single domain has many records and why editing the wrong one breaks something unrelated.
A — maps a name to an IPv4 address. The basic "where is this website" record.
AAAA — the same for IPv6. Pronounced "quad A".
CNAME — an alias pointing one name at another name, not at an address. www.example.com might be a CNAME to example.com, so changing the underlying address updates both.
The rule people fall over: a CNAME cannot coexist with other records at the same name. This is why you cannot normally put a CNAME on a bare domain (example.com) — it already has MX and NS records there. Providers work around it with non-standard ALIAS or ANAME records that behave like a CNAME but resolve server-side.
MX — where email for the domain should be delivered. Carries a priority number, and lower is higher priority, which is counterintuitive and routinely got backwards. Multiple MX records give failover.
MX records are entirely independent of the website. Changing hosting does not move email unless you change MX too — and accidentally replacing MX records when moving a site is the classic way to silently lose all incoming mail.
TXT — arbitrary text, now used mostly for verification and email authentication:
SPF — which servers may send mail for this domain.
DKIM — public key for verifying message signatures.
DMARC — what receivers should do when SPF or DKIM fail, and where to send reports.
Domain ownership verification for various services.
NS — which name servers are authoritative. These must match the delegation at your registrar.
SRV — service location with port and priority, used by VoIP and messaging protocols.
CAA — which certificate authorities may issue certificates for the domain, limiting misissuance.
PTR — reverse lookup from address to name, controlled by whoever owns the IP block rather than by you, and important for mail server reputation.
SOA — administrative parameters for the zone, including the negative caching TTL.