Because Twitter posts consisting of YouTube links die quickly. It’s very obvious once you have a few thousand followers.
Your option is basically either upload to twitter, or put the YouTube link at the end just before a screenshot. Or both a video and a YouTube link, I suppose.
If you trigger their YouTube embed, it seems like it gets penalized quite harshly. I’ve seen other people agree with the sentiment.
Just don't use a Twitter post as your demo video in the GitHub readme. I don't care what someone does on Twitter - I never go there. But you can just embed a .gif or .webm in your readme or link to YouTube there.
Twitter posts never die if you never post to Twitter in the first place.