  We resolve the nature of the quantum phase transition between a N\'eel
antiferromagnet and a valence-bond solid in two-dimensional spin-1/2 magnets.
We study a class of $J$-$Q$ models, in which Heisenberg exchange $J$ competes
with interactions $Q_n$ formed by products of $n$ singlet projectors on
adjacent parallel lattice links. QMC simulations provide unambiguous evidence
for first-order transitions, with the discontinuities increasing with $n$. For
$n=2$ and $n=3$ models, the first-order signatures are very weak. On
intermediate length scales, we extract well-defined scaling dimensions
(critical exponents) that are common to the models with small $n$, indicating
proximity to a quantum critical point. By combining two $Q$ terms, the
transition can be tuned from weak to more strongly first-order. The two
coexisting orders on the first-order line scale with a large exponent $\beta
\approx 0.85$. This exponent and others are close to bounds for an SO($5$)
symmetric CFT with a relevant SO($5$) singlet. We characterize the emergent
SO($5$) symmetry by the scaling dimensions of its leading irrelevant
perturbations. The large $\beta$ value and a large correlation length exponent,
$\nu \approx 1.4$, partially explain why the transition remains near-critical
even quite far away from the critical point and in many different models
without fine-tuning. In addition, we find that few-spin lattice operators are
dominated by the SO($5$) violating field (the traceless symmetric tensor), and
interactions involving many spins are required to observe strong effects of the
relevant SO($5$) singlet. The exponent that had previously been identified with
the divergent correlation length when crossing between the two phases does not
have a corresponding CFT operator. We explain this emergent pseudocritical
scale by a mechanism relying on a dangerously irrelevant SO($5$) perturbation.
