If I understand this code correctly, I takes any request to a .jpg, .jpeg, .png or .gif image and reroutes it to a URL with the same file name but with the .webp extension. But no such file exists.
Please try commenting out or removing this block and see if that helps. Please make sure to check the URL in private browsing/incognito mode to avoid problems with browser cache.