The impact of magnetoelasticity on structural phase transitions in cubic ferromagnets