YAML and JSON describe the same data model, so anything expressible in one can be expressed in the other. They differ only in surface syntax: JSON uses braces and quotes, YAML uses indentation and is far easier to write by hand and to comment.
Converting between them comes up constantly once you work with infrastructure. Kubernetes manifests, GitHub Actions workflows, Docker Compose files and OpenAPI specs are conventionally YAML, while most APIs, test fixtures and programmatic tooling expect JSON. Going YAML to JSON is usually about feeding a config file into something that only speaks JSON. Going the other way is usually about turning a generated payload into something a human will be editing and reviewing.
The conversion is also a quick way to check that YAML means what you think it means. YAML has some famously surprising corners: an unquoted yes or no becomes a boolean, a leading zero can make a number octal, and a value like 1.20 loses its trailing zero. Seeing the JSON equivalent shows you the actual parsed types rather than the characters you typed, which is often how a configuration bug gets spotted.
Comments are worth knowing about in advance. YAML supports them and JSON does not, so comments are dropped when converting to JSON. There is nowhere for them to go, and a round trip through JSON will not bring them back.