Flag Physics seems fine when on the viewport but looks messed up when rendered
Do you have any subdiv modifiers for that flag? If so make sure they have the same amount of subdiv steps on render and viewport. Because the gif you posted seems to have more geometry on it than the last image you posted...