Hi,
By referring to Max 10 GPIO user guide, Figure 1, 10M02 and 10M04 devices are migratable. https://www.intel.com/content/dam/www/programmable/us/en/pdfs/literature/hb/max-10/ug_m10_gpio.pdf
However, there is no information available to confirm if it is exact drop in replacement part. You would need to further verify thru Quartus Prime software with migration feature enable. When the migration feature is enabled in your design, you should always follow the common pin placement as stated in the Quartus Prime software Pin Migration Window in the Pin Planner.
Thank you
Regards,
Chia Ling