The casualties were with a force that entered Gaza City and seized buildings as part of a resumed attack on the refugee camp, Xinhua news agency reported.
Two IDF tanks, positioned several dozen meters away, apparently spotted a gun in a window of one of the buildings and fired two shells towards the target.
The army said it was investigating why the soldiers were misidentified as Palestinian militants.
A total of 626 soldiers have been killed in Hamas' Oct. 7 attack and Israel's ensuing attacks on Gaza, according to the IDF tally.