This is a direct consequence of two things: Hamas not wearing uniforms in combat and their tendency to use suicide bombers. They are told to undress themselves before processing - they don't stay that way.
How would any of the people criticizing this deal with a large group of fighting age men in a war zone?
No, it's based on safety. You can't give them their own clothing back, because this would require you to check each and every item of clothing for weapons. They are being transported to a processing location, given clothing there. Temperatures were around 20° C (68° F) there when these videos and photos were taken, so it's not like they were freezing.
the men are asked to undress by themselves? so they have their hands free and could grab any weapon inside their clothes? or are they undressed by the soldiers? The first doesnt make sense because then the argument of safety is mood. the second doesnt make sense because the soldiers would find any weapons that are in the clothes.
Then you say they are transported to a "processing location" Then why is there videos of people sitting there for hours? why is there no transport vehicle on site? Why wouldnt people be checked for weapons and then secured inside a transport vehicle?
But even leaving all of this aside. The men have their hands tied behind their backs. How would they be able to attack a soldier with a weapon that somehow was not found in the checks before? Firearms are simply impossible to hide. So the only thing that somehow could have slipped passed would be tiny shivs. How would someone that somehow managed to reach for a small shiv in his pocket be a danger to a soldier with his hands tied behind the back? Did you ever try walking backwards on a straight line? Now imagine doing so with your hands tied and trying to hit the right angle so you can inflict a wound upon someone who wears body armor.
Further considerations: Why would someone with the goal to fight the IDF wait to get detained to then try such a ridiculous maneuver, where the margin of success is nonexistent and death is certain? It would make much more sense to shoot at them from a window when they walk down the street.
And finally: If there is a true military need to act like this, why did we not see these kind of pictures on a regular basis from the Ukrainian military?
I fail to see a military justification for this. Especially since other militaries are perfectly capeable to handle suspects and POWs without stripping them down like this.
They are outnumbered, guns are being pointed at them as they are undressing, armored vehicles watch the whole thing and it's right in the open. There's at least one potentially spicy drone circling overhead. If any one of these people wants to die a martyr's death, that's all he's going to achieve.
Then why is there videos of people sitting there for hours?
No idea what you watched, but there is no multiple hour long video of this event, only short snippets and a handful of photos. Instead, they are being shown stepping into trucks, with some men already sitting there.
The men have their hands tied behind their backs.
That's after they have undressed and surrendered their weapons. There is a video of a man bringing their guns to the Israeli soldiers one after the other, over his head.
Why would someone with the goal to fight the IDF wait to get detained to then try such a ridiculous maneuver, where the margin of success is nonexistent and death is certain?
Ask Japanese soldiers that pulled these stunts in WW2, North Korean soldiers that did so during the Korean war, Vietcong that fainted surrender, various Islamist extremists who have done exactly this in the past. It's not rational behavior, because these men are being indoctrinated into a very contradictory, very irrational belief system. They are being taught from kindergarten that dying for your cause is the most honorable thing a man can do.
If there is a true military need to act like this, why did we not see these kind of pictures on a regular basis from the Ukrainian military?
Except we do. I have seen exactly this in photos and videos from Ukraine - except that the Ukrainians were far rougher with their Russian detainees and the colder temperatures made the whole deal far less pleasant for the POWs. Footage of this kind is very rare though and for an obvious reason: People who aren't well informed easily get outraged and it can be used for counter propaganda.
You may not want to "check for weapons" a suicide bomber who's just waiting for you to come close to turn you both into tiny chunks of meat.
What you want, is to threaten them with a weapon from a distance, have them take off any clothes that could contain explosives (that includes socks and briefs), and throw them far away from you. They could still hide some C4 up their ass, but that's a risk you might have to take.
The correct thing would be to subsequently provide them with pre-checked clothes, like an orange jumpsuit... so if they didn't, that's where we may agree it starts being abusive (although unfortunately in line with what many countries routinely do to their prisoners).