Understanding the magnetostructural transformation in FeRh thin films