I am having the exact same issue. My Drupal version is 9.5.10 and I have tried all the above things that are mentioned above. Still no luck. @umarkhan82 , did you have any luck finding an answer?
I recently had an issue where when I would upload a new image (and before saving the form), the image uploads via ajax (standard with drupal), but the thumbnail showed broken. I checked and the thumbnail was available in files directory. The image would show when i would right lcick on the broken thumbnail and hit "load image". After stumbling on many things I found it was a blank space at the start of one of my custom module files.
So it is likely the space is at a place where you have added/updated some code. Check your custom modules, themes etc files.
I recently had an issue where when I would upload a new image (and before saving the form), the image uploads via ajax (standard with drupal), but the thumbnail showed broken. I checked and the thumbnail was available in files directory. The image would show when i would right lcick on the broken thumbnail and hit "load image". After stumbling on many things I found it was a blank space at the start of one of my custom module files. This thread helped.
https://www.drupal.org/project/drupal/issues/2195311 💬 Image styles not generated on first page load until page refreshed Fixed