Both write data as text, but they're suited to different jobs.
At a glance
JSON — strict braces and quotes. Great for machines talking to each other; nearly every language reads it out of the box. No comments.
YAML — indentation shows structure, so it's easy for people to read and write. Supports comments (#), so it's popular for config files.
Common YAML mistakes
Indent with spaces, not tabs
no, yes, on and off may be read as booleans — quote them if they're text
Without a space after the colon (:), it isn't read as a value
Numbers like 0123 may be read as octal or as text
Which to use
JSON for APIs and data exchange, YAML for config files people edit. They convert into each other, so switch with “JSON ⇄ YAML Converter” whenever you need to.