How are you supposed to argue against something if you don't even understand why someone supports what they support? All you will end up doing is strawmaning their views which won't convince anybody to change their views.
Do I need to understand why someone supports flat earth theory to be able to argue that it's scientifically invalid? Why is it up to me to figure out how they got deluded?
You only need to understand their positions if you want to argue against it. Since like 5 people actually believe in a flat earth (there are a lot of memers) it probably isn't worth the effort to learn about their positions. For more mainstream issues you should absolutely understand all sides of an issue to the best of your abilities. Many people only understand generals and miss a lot of nuance when it comes to their opponent's views.
If you are going to argue with a flat earther they will not accept the arguments you will make if you just argue for a round earth. You can show them some math, images from space, eyewitness testimony or whatever you want, but they have almost certainly seen it all before. They were unconvinced by those arguments in the past and you will likely not be any more convincing to them. The only way to convince them is to tear down their arguments one by one which means you have to actually know what they believe. If you tear down strawman arguments they don't even believe they won't change their mind.
Just to be clear, when you say it is not up to you to figure out how they got deluded. I agree. You don't have to know what books or videos or whatever they consumed. You only need to understand the views themselves.
How can you both show a claim is scientifically invalid and simultaneously not understand the claim? The "why" here is the "why of the claim" not the "why they came to think that" (though the latter may still be useful if you're trying to convince someone but that's a different issue).
You don't have to argue with flat earthers if you don't want to. But if you're going to argue against that position then yes, you absolutely must first understand why they hold it. Otherwise you'll spend all your time attacking straw men and get nowhere with your argument.