Uncovering selective excitations using the resonant profile of indirect inelastic x-ray scattering in correlated materials: Observing two-magnon scattering and relation to the dynamical structure factor