Sadly, the real world can be a bit more filthy than what you learn in school.
The good news is that if you're in control of the image throughout its creation and delivery, it will be lossless. However, on Twitter you aren't.
Edited to add: I'm posting this at the risk of hammering the nail out of sight, but I feel that there's value in knowing about this.

This was one of my own assets, uploaded as a PNG to Fiverr at greater than 1x1 ratio. I didn't apply any pre-processing. I previewed the image in the browser on the Fiverr site, blew it up to focus in on the sub-pixel artefacts, and took a screenshot.
Once I uploaded the image to Fiverr, I lost control of it. They could be doing anything they want with it. Maybe the preview feature uses a more compressed image than downloads to save on their bandwidth costs?
Twitter and Instagram are notoriously hard to upload to without some kind of distortion as well. Blurry edges for example. (There's a bit of a secret sauce for Twitter that, if you get it right, lets you get a clean image, but if you upload 1x scale pixel art you'll be in a world of pain.)
We tend to use Imgur on this forum because it keeps the PNG intact and lossless. Not all platforms do, by the looks of it. And to be honest, I don't blame them. Reducing bandwidth charges probably saves a great deal of money. Also, pixel art is pretty niche, and other art forms don't tend to suffer quite as much when compressed.
But yeah, if you have a JPG you'll have distortion (and really messy distortion at that), but if you have a PNG you'll most likely have a clean image. But PNGs are not immune.