This would cause the downloaded file to have incorrect file extension because such services don't configure the Content-Disposition header properly, and you still may have lots of improperly named files unless you realize that the file content doesn't match its extension.
No, the server is just sending the file named 'foo.jpg', but encoded as a webp with webp mime type, so when you save the file it defaults to the webp extension cause it ends up treating the filename as a blob of text without an expected extension for the file type.
Annoyingly, this doesn't work for a whole lot of websites that insist on serving webp, they just ignore the header. Some of them have bespoke workarounds like adding ?format=original on fandom wikis, with some the server will just never serve you anything other than webp.